Jump to content

JavaScript Unix timestamp?


grippat

Recommended Posts

You can try this:a = new Date()var d = Number(Date.UTC(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),0));d = d/1000;// d would be the Unix timestamp for this moment.

Link to comment
Share on other sites

valueOf() uses the getTime() implementation internally which means that as with getTime() it returns a timestamp which is ms since the epoch, however the unix timestamp is seconds since the epoch. So we need to divide by 1000 and then perform a round to get an integer.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...