UTC (JavaScript)

Calculates a time in UTC.

Defined in

Date (Standard - JavaScript)

Syntax

UTC(year:int, month:int) : long

UTC(year:int, month:int, day:int) : long

UTC(year:int, month:int, day:int, hours:int) : long

UTC(year:int, month:int, day:int, hours:int, minutes:int) : long

UTC(year:int, month:int, day:int, hours:int, minutes:int, seconds:int) : long

UTC(year:int, month:int, day:int, hours:int, minutes:int, seconds:int, ms:int):long

Parameters Description
year The year in UTC. Specify the entire year, for example, 2006 not 06.
month The month in UTC where 0 is January and 11 is December.
day The day of the month in UTC where 1 is the first day. Defaults to 1.
hours The hour in UTC where 1 is 1:00 AM and 13 is 1:00 PM. Defaults to 0 (12:00 AM).
min The minute in UTC where 1 is the first minute. Defaults to 0.
sec The second in UTC where 1 is the first second. Defaults to 0.
ms The millisecond in UTC where 1 is the first millisecond. Defaults to 0.
Return value Description
long The date in numeric form.

Examples

The following computed labels create dates based on UTC specifications.
var date = new Date().UTC(2004, 1);
date.toUTCString()
// 01-Feb-2004 00:00:00
var date = new Date().UTC(2004, 1, 15);
date.toUTCString()
// 15-Feb-2004 00:00:00
var date = new Date().UTC(2004, 1, 15, 14);
date.toUTCString()
// 15-Feb-2004 14:00:00
var date = new Date().UTC(2004, 1, 15, 14, 30);
date.toUTCString()
// 15-Feb-2004 14:30:00
var date = new Date().UTC(2004, 1, 15, 14, 30, 15);
date.toUTCString()
// 15-Feb-2004 14:30:15
var date = new Date().UTC(2004, 1, 15, 14, 30, 15, 500);
date.toUTCString() + " " + date.getUTCMilliseconds() + "ms"
// 15-Feb-2004 14:30:15 500ms