Javascript Date getUTCMinutes()

Introduction

Javascript Date getUTCMinutes() returns the UTC date's minutes as a number between 0 and 59.

Return value

An integer number, between 0 and 59, representing the minutes in the given date according to universal time.

var today = new Date();
var minutes = today.getUTCMinutes();
console.log(minutes);//from w w  w .  j  a v a 2s .  c om

Return the UTC minutes from a specific date and time:

var d = new Date("July 21, 2010 01:15:00");
var n = d.getUTCMinutes();
console.log(n);/*from w ww. j  ava2  s.c o m*/

Using getUTCHours(), getUTCMinutes(), and getUTCSeconds() to display the universal time:

function addZero(i) {
  if (i < 10) {
    i = "0" + i;/*  w  ww. jav 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);



PreviousNext

Related