JavaScript Date getTime() Method
- Previous Page getSeconds()
- Next Page getTimezoneOffset()
- Go to the Previous Level JavaScript Date Reference Manual
Definition and Usage
getTime()
The method returns the number of milliseconds between midnight on January 1, 1970, and the specified date.
Instance
Example 1
Return the milliseconds since 1970/01/01:
var d = new Date(); var n = d.getTime();
Example 2
Calculate the number of years since 1970/01/01:
var minutes = 1000 * 60; var hours = minutes * 60; var days = hours * 24; var years = days * 365; var d = new Date(); var t = d.getTime(); var y = Math.round(t / years);
Syntax
Date.getTime()
Parameters
No parameters.
Technical Details
Return Value: | A number representing the milliseconds since midnight on January 1, 1970. |
---|---|
JavaScript Version: | ECMAScript 1 |
Browser Support
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
getTime() | Support | Support | Support | Support | Support |
Related Pages
Tutorial:JavaScript Date
Tutorial:JavaScript Date Format
Tutorial:JavaScript Object Constructor
- Previous Page getSeconds()
- Next Page getTimezoneOffset()
- Go to the Previous Level JavaScript Date Reference Manual