How To Get Timestamp In JavaScript or jQuery




Here we consider how to get timestamp in javascript. To get UTC timestamp in millseconds, you can use Date.now()




var milliseconds = Date.now(); -- New Method

var milliseconds = new Date().getTime(); -- Old Method



To get in seconds you can use following code.



var seconds =
Math.floor( Date.now() / 1000 ); -- New Method

var seconds =
Math.round( new Date().getTime()/1000 ) -- Old Method