The getUTCSeconds() method returns the seconds ranged from 0 to 59 of the date object, according to universal time.
The getUTCSeconds() method returns the seconds ranged from 0 to 59 of the date object, according to universal time.
UTC time is the same as GMT time.
Date.getUTCSeconds()
None
A Number, from 0-59, representing the seconds
Return the seconds, according to universal time:
//display seconds, according to UTC. var d = new Date(); var n = d.getUTCSeconds(); console.log(n);/* www . ja va 2s . com*/
Using getUTCHours(), getUTCMinutes(), and getUTCSeconds() to display the universal time:
//display the UTC time. function addZero(i) { if (i < 10) { i = "0" + i; }/*w ww. j a v a 2 s .co m*/ return i; } var d = new Date(); var h = addZero(d.getUTCHours()); var m = addZero(d.getUTCMinutes()); var s = addZero(d.getUTCSeconds()); console.log( h + ":" + m + ":" + s);