JavaScript now() Method
Example
Return the number of milliseconds since 1970/01/01:
var n = Date.now();
The result of n could be:
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The now() method returns the number of milliseconds since January 1, 1970 00:00:00 UTC.
Browser Support
Method | |||||
---|---|---|---|---|---|
now() | Yes | Yes | Yes | Yes | Yes |
Syntax
Date.now()
Parameters
None |
Technical Details
Return Value: | A Number, representing the number of milliseconds since midnight January 1, 1970 |
---|---|
JavaScript Version: | 1.5 |
More Examples
Example
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);
The result of y will be:
Try it Yourself »
JavaScript Date Object