EN
JavaScript - get UNIX timestamp in milliseconds
6
points
In this short article, we would like to show how to get unix timstamp in milliseconds in JavaScript.
Note: as unix timestamp in this article we understans bash
date +%s%3N
command result.
Quick solution:
// ONLINE-RUNNER:browser;
const now = Date.now();
console.log(now); // 1639930461139
Reusable source code
// ONLINE-RUNNER:browser;
const getTimestamp = () => {
return Date.now();
};
// Usage example:
const now = getTimestamp();
console.log(now); // 1639930461139