The JavaScript getMinutes function is one of the date methods that returns the minutes value ranging from 0 to 59 on the given date according to local time.
The syntax of the getMinutes() function is
dateObject.getMinutes()
Return Value: It returns an integer between 0 and 59 representing the minutes value from the given date according to the local time. For any invalid dates, it returns NaN.
JavaScript getMinutes example
The following set of examples helps understand the getMinutes() method.
Example 1: The following getMinutes() function returns the minutes value in the current date and time.
const dt = new Date()
const m = dt.getMinutes()
console.log(m);
console.log(dt.toString());
18
Sun Jun 07 2026 11:18:47 GMT+0530 (India Standard Time)
Example 2: In this example, we use the getMinutes() method to extract the minutes from the custom date and time.
const dt = new Date("April 31, 2022 12:19:07");
console.log(dt.getMinutes());
19
Example 3: In this JavaScript example, we extract minutes from a custom date without time (hh:mm:ss). As there is no minute value, the JavaScript getMinutes() function returns 0 minutes.
const dt = new Date("April 31, 2022");
console.log(dt.getMinutes());
0
Example 4: As mentioned earlier, when we use the getMinutes() function on an invalid date, it returns NaN. Here, we used the month value as 14, which does not exist, so it returns NaN.
const dt = new Date("14-13-2022 10:11:12");
console.log(dt.getMinutes());
NaN
JS getMinutes with leading zero
const dt = new Date("04-13-2022 10:2:12");
const m = String(dt.getMinutes()).padStart(2, '0');
console.log(m);
02