The getMinutes() method returns the minutes ranged from 0 to 59 of the date object.
The getMinutes() method returns the minutes ranged from 0 to 59 of the date object.
Date.getMinutes()
None
A Number, from 0 to 59, representing minutes
Return the minutes, according to local time:
//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);
Using getHours(), getMinutes(), and getSeconds() to display the time:
//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);