JavaScript tutorial:
getUTCMonth method

 

Applies to: Date Object

The getUTCMonth method is use to get the month value value in a Date object using Universal Coordinated Time (UTC).

Syntax

objDate.getUTCMonth()

Return

Returns the month value value in a Date object using UTC.

Example

To get the month in local time, use the getMonth method.

The getUTCMonth method returns an integer between 0 and 11 indicating the month value in the Date object. The integer returned is not the traditional number used to indicate the month. It is one less. If "Jan 5, 1996 08:47:00.0" is stored in a Date object, getUTCMonth returns 0.

The following example illustrates the use of the getUTCMonth method:

s = "Today's UTC date is: ";
d = new Date();
s += (d.getUTCMonth() + 1) + "/";
s += d.getUTCDate() + "/";
s += d.getUTCFullYear();

document.write(s)

  To run the code above, paste it into JavaScript Editor, and click the Execute butto

See also: Date Object Methods, getMonth Method, setMonth Method, setUTCMonth Method