Google analytics code

Friday, January 10, 2014

Javascript: Quick Date timestamp

I wanted to find a quick way to compare two dates. The easiest way is to use their unix timestamp. If the date exists as an object you can use .getTime() to retrieve the number of milliseconds that have passed since epoch time.

You can retrieve that number even faster with the following bit of code

+new Date

I found the tip here and wanted to surface it.

No comments:

Post a Comment

If you found this page useful, or you have any feedback, please leave a comment.