Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript getUTCMonth() Method

JavaScript getUTCMonth() Method

Date Object Reference JavaScript Date object

Example

Return the month according to universal time (UTC):

var d = new Date();

var n = d.getUTCMonth();

n Output result:

Try it »


Definition and Usage

The getUTCMonth() method returns a number representing the month (according to universal time UTC).

Note: January is 0, February is 1, and so on.

Coordinated Universal Time (UTC) is a time measurement system based on the atomic second, designed to stay as close as possible to universal time.

**Tip:** Coordinated Universal Time, also known as Universal Time, World Standard Time, or International Coordinated Time, abbreviated as UTC (Universal Coordinated Time).

**Note:** UTC time is the same as GMT (Greenwich) time.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the getUTCMonth() method.


Syntax

Date

.getUTCMonth()

Return Value

Type Description
Number The value is an integer between 0 (January) and 11 (December).

Technical Details

JavaScript version: 1.3

More examples

Example

Now we will create an array so that our example above can output the name of the month instead of just a number:

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()];

n Output result:

Try it »


Date Object Reference JavaScript Date object