Date.UTC() (Method/static)

A class based factory method for converting numeric values to Date objects.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server - 2.0
Opera - 3.0
Property/method value type:UTC time in milliseconds
JavaScript syntax:  
-Date.UTC(aYear, aMonth)
-Date.UTC(aYear, aMonth, aDate)
-Date.UTC(aYear, aMonth, aDate, anHour)
-Date.UTC(aYear, aMonth, aDate, anHour, aMinute)
-Date.UTC(aYear, aMonth, aDate, anHour, aMinute, aSecond)
- (JavaScript 1.3 +)Date.UTC(aYear, aMonth, aDate, anHour, aMinute, aSecond, aMillisecond)
Argument list:aDateAn optional date within the month value
aMillisecondAn optional value between 0 and 999 milliseconds
aMinuteAn optional value between 0 and 59 minutes
aMonthAn optional 0 to 11 month value
anHourA value between 0 and 23 hours
aSecondAn optional value between 0 and 59 seconds
aYearA full year value
aValueA time in UTC milliseconds

This method returns a date value with the indicated date and time value.

When the Date.UTC() method is called, it interprets the arguments as UTC time values and returns a number representing the UTC time in milliseconds.

The value stored in the new date object depends on the argument values that are supplied. The arguments are all optional but are positional so, if an argument is missing, it is assumed to be the last argument and so on.

Functionally, the algorithm that manufactures a new date value uses the internal MakeDay(), MakeTime() and MakeDate() methods that we describe elsewhere.

If the year value is less than 99, then the date creation adds 1900 to it and assumes the date is in the 20th century. To avoid millennium problems, always specify a full year number.

Where arguments are omitted, zero values are assumed for hours, minutes and seconds. When all three are missing, the time is assumed to be midnight.

An incomplete date with zero, one or two arguments will behave in an implementation dependent way and might yield a different result depending on the platform supporting the script interpreter.

See also:Date(), Date.constructor, MakeDate(), MakeDay(), MakeTime(), TimeClip()

Cross-references:

ECMA 262 edition 2 - section - 15.9.4.3

ECMA 262 edition 2 - section - 15.9.4.4

ECMA 262 edition 2 - section - 15.9.4.5

ECMA 262 edition 2 - section - 15.9.4.6

ECMA 262 edition 2 - section - 15.9.4.7

ECMA 262 edition 2 - section - 15.9.4.8

ECMA 262 edition 2 - section - 15.9.4.9

ECMA 262 edition 2 - section - 15.9.4.10

ECMA 262 edition 3 - section - 15.9.4.3