Javascript - Date Current Time

Introduction

Date.now() returns the millisecond representation of the date and time at which the method is executed.

You can use it to time your code:

//get start time
var start = Date.now();

//call a function
doSomething();

//get stop time
var stop = Date.now(),
    result = stop - start;

You can simulate the now() behavior by using the + operator to convert a Date object into a number:

//get start time
var start = +new Date();

//call a function
doSomething();

//get stop time
var stop = +new Date(),
    result = stop - start;