getTime()
Date
instance method
JS Home <<
JS Reference <<
Date <<
getTime()
Description
Returns the number of milliseconds since 1 January 1970 00:00:00 UTC. Dates prior to this will return a negative value.
Syntax
Signature | Description |
---|---|
aDate.getTime() | Returns the number of milliseconds since 1 January 1970 00:00:00 UTC . Dates prior to this will return a negative value. |
Parameters
None.
Examples
The code below shows an example of the getTime()
method of Date
.
// Create a Date instance for the current date and time.
var todaysDate = new Date();
alert(todaysDate);
// Get number milliseconds since 1 January 1970 00:00:00 UTC.
alert(todaysDate.getTime() +
' = milliseconds since 1 January 1970 00:00:00 UTC');
Related Tutorials
JavaScript Intermediate Tutorials - Lesson 2 - Dates and Times