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)
# 1730528480.8333
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)
# 1730528480.8333
Tags
Related Articles
- How To Convert Timestamp To Date and Time in JavaScript
- How To Get Current Date And Time in JavaScript
- How To Get Current Timestamp In Bash
- How To Get Current Timestamp In Java
- How To Get Current Timestamp In PHP
- How To Get Current Timestamp In Python
- Timestamp To Date
- How To Convert Timestamp To Date and Time in Python
- How To Get Current Time In Python