0 votes
1 view
in Web Technology by (47.8k points)

How can I get a timestamp in JavaScript?

Something similar to Unix's timestamp, that is, a single number that represents the current time and date. Either as a number or a string.

1 Answer

0 votes
by (107k points)

For getting a timestamp in JavaScript almost all current browsers you can use Date.now()method and it will return the UTC timestamp in milliseconds.

See the code below:-

if (!Date.now) { 

Date.now = function() { 

return new Date().getTime(); 

  } 

}

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...