Javascript Date getUTCMonth()

Introduction

Javascript Date getUTCMonth() method returns the month of the UTC date, where 0 represents January and 11 represents December.

Return value

An integer number, between 0 and 11, corresponding to the month of the given date according to universal time.

0 for January, 1 for February, 2 for March, and so on.

var today = new Date();
var month = today.getUTCMonth();
console.log(month);/* w w w. ja  va 2s .  c  o m*/

Return the name of the month, according to universal time:

var d = new Date();
var month = new Array(12);
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";

var n = month[d.getUTCMonth()];
console.log(n);/*from  w  ww.j  a  v  a  2  s  . co  m*/



PreviousNext

Related