Date.now!

Here\’s a little cool snippet I picked up from MDN. It\’s how to implement the Date.now method in browsers that don\’t currently support it. The method returns a number value in milliseconds from 1 January 1970 00:00:00 UTC till now.

if (!Date.now) {
  Date.now = function now() {
    return +(new Date);
  };
}

One thought on “Date.now!”

Leave a Reply

Your email address will not be published. Required fields are marked *