How to get a timestamp in JavaScript

Below are the ways to get a timestamp in Javascript. returns the UTC timestamp in milliseconds.

If you are using IE you can use the below code.

if (! { = function now() {
        return new Date().getTime();
To convert the timestamp in seconds use below code

Math.floor( / 1000)

No comments:

Post a Comment

Please Provide your feedback here