UNIX timestamps in js

It is a matter of seconds

Posted by on April 04, 2017 UNIX timestamps in js

I need a valid unix timestamp from javascript in a recent project. You just need to transform milliseconds to seconds with following call

Math.round(new Date().getTime()/1000)

I recommend to create a prototype on the date object.

This piece of code is valid for IE9+, Chrome, Firefox, Safari.