How to get Unix timestamp in Javascript?


How to get Unix timestamp i.e current time in seconds in Javascript?

1 Answer

5 years ago by

Following code gets Unix timestamp i.e Unix epoch time

var unixTimestamp = Math.round( +new Date() / 1000);

If you want to get milliseconds you can do the following

var currentTimeInMillies = +new Date();
5 years ago by Karthik Divi