Visit Mozilla.org

Core JavaScript 1.5 Reference:Global Objects:Date:getTime

From MDC


Contents

[edit] Summary

Returns the numeric value corresponding to the time for the specified date according to universal time.

Method of Date
Implemented in: JavaScript 1.0, NES 2.0
ECMA Version: ECMA-262

[edit] Syntax

getTime()

[edit] Parameters

None.

[edit] Description

The value returned by the getTime method is the number of milliseconds since 1 January 1970 00:00:00. You can use this method to help assign a date and time to another Date object.

This method is functionally equivalent to the valueOf method.

[edit] Examples

[edit] Example: Using getTime

The following example assigns the date value of theBigDay to sameAsBigDay:

theBigDay = new Date("July 1, 1999")
sameAsBigDay = new Date()
sameAsBigDay.setTime(theBigDay.getTime()) 

[edit] See also

getUTCHours, setTime, valueOf