Skip to content

Get epoch or Unix timestamp in JavaScript

We can get current epoch or unix timestamp in JavaScript using Date() objects and getTime() function.

Advertisements

The getTime() function returns timestamp in milliseconds. We can get current unix timestamp in seconds using below code.

var date = new Date();
var timestamp = Math.floor(date.getTime()/1000.0);
console.log(timestamp); //1601529050
See also  Какой язык программирования учить первым: онлайн-интенсив

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.