Asked by bgcode
See @James McMahon’s response for further details.
Answered by ExpExc
The correct way is, as Wizzard pointed out.
From the documentation,
You can use if you want to make a time stamp without milliseconds.
Math.floor(Date.now() / 1000);
I wanted to make this a response so that the correct way would be more obvious.
At http://jsfiddle.net/JamesFM/bxEJd/, you can compare ExpExc’s and Narendra Yadala’s results to the approach above, and verify with http://www.unixtimestamp.com/ or by running date + percent s on a Unix terminal.
Answered by James McMahon
To acquire the time stamp in the UTC timezone, use the Date.UTC method.
var now = new Date; var utc_timestamp = Date.UTC(now.getUTCFullYear(),now.getUTCMonth(), now.getUTCDate() , now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds());
Live demo here http://jsfiddle.net/naryad/uU7FH/1/
Answered by Narendra Yadala
“… that don’t care about their time zone”
var timezone = d.getTimezoneOffset() // difference in minutes from GMT
Answered by abuduba
Post is based on https://stackoverflow.com/questions/8047616/get-a-utc-timestamp