Performance – Date.now() vs Date.getTime()

These things are the same (edit semantically; performance is a little better with .now()):

var t1 = Date.now();
var t2 = new Date().getTime();

However, the time value from any already-created Date instance is frozen at the time of its construction (or at whatever time/date it’s been set to). That is, if you do this:

var now = new Date();

and then wait a while, a subsequent call to now.getTime() will tell the time at the point the variable was set.

Leave a Comment