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:
xxxxxxxxxx
1
const now = Date.now();
2
3
console.log(now); // 1639930461139
xxxxxxxxxx
1
const getTimestamp = () => {
2
return Date.now();
3
};
4
5
6
// Usage example:
7
8
const now = getTimestamp();
9
10
console.log(now); // 1639930461139