Javascript - Date getMinutes() Method

The getMinutes() method returns the minutes ranged from 0 to 59 of the date object.

Description

The getMinutes() method returns the minutes ranged from 0 to 59 of the date object.

Syntax

Date.getMinutes()

Parameters

None

Return

A Number, from 0 to 59, representing minutes

Return the minutes, according to local time:

Demo

//display the minutes of the time right now.
var d = new Date();
var n = d.getMinutes();
console.log(n);/* w  w w .j a va  2s.c om*/

//Return the minutes from a specific date and time:
var d = new Date("July 21, 2010 01:15:00");
var n = d.getMinutes();
console.log(n);

Result

Using getHours(), getMinutes(), and getSeconds() to display the time:

Demo

//display the time.
function addZero(i) {
    if (i < 10) {
        i = "0" + i;
    }/*from   www  .j  a va 2s.  c o  m*/
    return i;
}

var d = new Date();
var h = addZero(d.getHours());
var m = addZero(d.getMinutes());
var s = addZero(d.getSeconds());
console.log( h + ":" + m + ":" + s);

Result