目录

JavaScript Date.now()

Examples

let ms = Date.now();
Try it Yourself »

Calculate the number of years since 1970/01/01:

const minute = 1000 * 60;
const hour = minute * 60;
const day = hour * 24;
const year = day * 365;

let years = Math.round(Date.now() / year);
Try it Yourself »

Description

Date.now() returns the number of milliseconds since January 1, 1970.

Notes

Date.now() is a static method of the Date object.

You cannot use it on a date like myDate.now()

The syntax is always Date.now().



Syntax

Date.now()

Parameters

NONE

Return Value

A number.

The number of milliseconds since midnight January 1, 1970 00:00:00 UTC.


Browser Support

Date.now() is an ECMAScript5 (ES5) feature.

ES5 (JavaScript 2009) fully supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes 9-11