Timestamp To Date Converter

Convert timestamp to date or date to timestamp easily

How To Get Current Timestamp In JavaScript

All functions for working with date and time in Javascript are in module Date. This module provides multiple ways how you can get current timestamp in JavaScript. Unlike other languages JavaScript provides number of microseconds elapsed since 1 January 1970 00:00:00 UTC. Other languages provides mostly just number of seconds.

Using Just Constructor

When object Date is created without any parameter it uses current time, so it is possible to get current timestamp with following code:


var ts = new Date().getTime()/1000;
console.log(ts)
# 1732134578.5243

Using Date.now()

Object Date also provides function now which also returns number of milliseconds elapsed since beginning of the epoch.


var ts = var ts = Date.now()/1000;
console.log(ts)
# 1732134578.5243
This website uses cookies to ensure you get the best experience on our website. More info