How to get Current Hour, Minute and Second in JavaScript?
August 13, 2020

Using JavaScript Date Objects we can get the current hour, minute and second as well as manipulate those numbers.

Get Hour

The getHours() method returns the current hour of any specified date. It will return hour from 0 to 23.

So, we can create a date object first and then using that date we can get the hour.

var d = new Date();

// 2

Get Minute

The getMinutes() method returns the current minutes from a date as a number from 0 to 59.

So, similarly like hour, we can create a date object first and then using that date we can get the current minute.

var d = new Date();

// 8

Get Second

The getSeconds() method returns the second of a date as a number between 0 to 59.

So, similarly like hour and minute, we can create a date object first and then using that date we can get the current second.

var d = new Date();

// 14

Leave a Reply

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to set opacity or transparency using CSS? #3 Pagination in CSS with multiple examples #4 How to make HTML form interactive and using CSS? #5 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

Mar 5 How to create flickering text using CSS? Mar 4 How to use data-* Attributes in HTML? Mar 4 The substr() method in JavaScript and how it’s different from substring() Mar 4 A complete guide to add responsive YouTube videos using HTML and CSS Mar 3 How to embed YouTube or other video links in WordPress? Mar 3 How to change the Login Logo in WordPress?

You might also like these

How to Find the Highest (or Lowest) Number in an Array in JavaScript?JavaScriptCSS align-items property examplesCSSLearn to create your skill bar using CSSCSSA Quick Comparison of JOIN and Subquery in SQLSQL/MySQLHTML Copyright SymbolHTMLCheck if any column has NULL values in PostgresPostgresLIKE and ILIKE Operators in PostgresPostgresWhat happens when we add Numbers and Strings in JavaScript?JavaScriptHow to Check If a Variable is an Integer, a Float, a Number, NaN, an Infinite or a Numeric in PHP?PHPThe order Property in Flex Items in CSSCSSHow to create flickering text using CSS?CSSHow to check if a link has http or https in it in JavaScript?JavaScript