JavaScript Date now() method
- Previous Page getUTCSeconds()
- Next Page parse()
- Go to Parent Layer JavaScript Date Reference Manual
Definition and usage
Date.now()
The method returns the number of milliseconds since 00:00:00 UTC on January 1, 1970.
Example
Example 1
Return the milliseconds since 1970/01/01:
var n = Date.now();
Example 3
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 t = Date.now(); var y = Math.round(t / years);
Syntax
Date.now()
Parameters
No parameters.
Technical details
Return value: | A number representing the milliseconds since midnight on January 1, 1970. |
---|---|
JavaScript version: | ECMAScript 5 (2009) |
Browser support
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
Date.now() | Support | 9 | Support | Support | Support |
- Previous Page getUTCSeconds()
- Next Page parse()
- Go to Parent Layer JavaScript Date Reference Manual