Gets the time value in milliseconds.
SyntaxdateObj.getTime()
Return Value
Returns the number of milliseconds between midnight, January 1, 1970 and the time value in the Date object. The range of dates is approximately 285,616 years from either side of midnight, January 1, 1970. Negative numbers indicate dates prior to 1970.
ExamplesThe following example shows how to use the getTime method.
var minute = 1000 * 60;
var hour = minute * 60;
var day = hour * 24;
date = new Date("1/1/2001");
var time = date.getTime();
document.write(Math.round(time / day) + " days from 1/1/1970 to 1/1/2001");
Remarks
The required dateObj reference is a Date object.
When doing multiple date and time calculations, you may want to define variables equal to the number of milliseconds in a day, hour, or minute. For example:
var minute = 1000 * 60;
var hour = minute * 60;
var day = hour * 24;
See Date and Time Calculations (Windows Scripting - JScript) for more information about how to use the getTime method.
See also Other articles AttributionsMicrosoft Developer Network: Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4