Section 24.68. Date.UTC( ): convert a Date specification to milliseconds


24.68. Date.UTC( ): convert a Date specification to milliseconds

ECMAScript v1

24.68.1. Synopsis

 Date.UTC(year, month, day, hours, minutes, seconds, ms) 

24.68.1.1. Arguments

year

The year in four-digit format. If this argument is between 0 and 99, inclusive, 1900 is added to it and it is treated as a year between 1900 and 1999.


month

The month, specified as an integer from 0 (January) to 11 (December).


day

The day of the month, specified as an integer from 1 to 31. Note that this argument uses 1 as its lowest value, while other arguments use 0 as their lowest value. This argument is optional.


hours

The hour, specified as an integer from 0 (midnight) to 23 (11 p.m.). This argument is optional.


minutes

The minutes in the hour, specified as an integer from 0 to 59. This argument is optional.


seconds

The seconds in the minute, specified as an integer from 0 to 59. This argument is optional.


ms

The number of milliseconds, specified as an integer from 0 to 999. This argument is optional and is ignored prior to ECMAScript standardization.

24.68.1.2. Returns

The millisecond representation of the specified universal time. That is, this method returns the number of milliseconds between midnight GMT on January 1, 1970 and the specified time.

24.68.2. Description

Date.UTC( ) is a static method; it is invoked through the Date( ) constructor, not through an individual Date object.

The arguments to Date.UTC( ) specify a date and time and are understood to be in UTC; they are in the GMT time zone. The specified UTC time is converted to the millisecond format, which can be used by the Date( ) constructor method and by the Date.setTime( ) method.

The Date( ) constructor method can accept date and time arguments identical to those that Date.UTC( ) accepts. The difference is that the Date( ) constructor assumes local time, while Date.UTC( ) assumes universal time (GMT). To create a Date object using a UTC time specification, you can use code like this:

 d = new Date(Date.UTC(1996, 4, 8, 16, 30)); 

24.68.3. See Also

Date, Date.parse( ), Date.setTime( )




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net