JavaScript Date now() method

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();

Try it yourself

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);

Try it yourself

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

Related Pages

Tutorial:JavaScript Date

Tutorial:JavaScript Date Format