javascript tutorial - timestamp in javaScript - javascript - java script - javascript array
Problem:
How to get a timestamp in JavaScript?
Solution 1:
Short & Snazzy:
To get the timestamp in seconds, we can use:
Or alternatively we could use:
Solution 2:
We like this, because it is small:
We also like this, because it is just as short and is compatible with modern browsers, and over 357 people voted that it's better:
Solution 3:
This will give we the milliseconds since the epoch (not Unix timestamp):