2 out of 4 rated this helpful - Rate this topic

Date.now Function (JavaScript)

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Returns the number of milliseconds between January 1, 1970, and the current date and time.

Date.now()

The number of milliseconds between midnight, January 1, 1970, and the current date and time.

The getTime method returns the number of milliseconds between January 1, 1970, and a specified date.

For information about how to calculate elapsed time and compare dates, see Date and Time Calculations (JavaScript).

The following example illustrates the use of the now method.

var startMSec = Date.now();
var response = prompt("What is your name?", "");
var endMSec = Date.now();
    
var elapsed = (endMSec - startMSec) / 1000;
document.write("You took " + elapsed + " seconds" + " to type: " + response);

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards. Also supported in Metro style apps. See Version Information.

Did you find this helpful?
(1500 characters remaining)