How To Get UNIX Timestamp In JavaScript

The Unix timestamp is the number of seconds between a specific date and the Unix Epoch. In this tutorial, we have explained how to get Unix timestamp in milliseconds and seconds using javascript.

Get UNIX Timestamp in miliseconds:

To get timestamp in miliseconds, you can use Date.now() method

Another method is with using valueOf() method, which returns the timestamp value of a Date object, which is the same as the total number of milliseconds since the Unix Epoch.

Get Timestamp in Seconds:

To get timestamp in seconds, use following code.

Check changing the format of Date and Time in PHP.

Recommended Posts For You

About Harish

I am professional web developer and blogger. Use this blog to share own api and other web development experience with you. I do accept paid work. Write to me at - [email protected]

View all posts by Harish