EN
TypeScript - get UNIX timestamp in milliseconds
0 points
In this short article, we would like to show how to get unix timstamp in milliseconds in TypeScript.
Note: as unix timestamp in this article we understans bash
date +%s%3N
command result.
Quick solution:
xxxxxxxxxx
1
const now: number = Date.now();
2
3
console.log(now); // Example output: 1648547761676
xxxxxxxxxx
1
const getTimestamp = (): number => {
2
return Date.now();
3
};
4
5
6
// Usage example:
7
8
const now: number = getTimestamp();
9
10
console.log(now);
Example output:
xxxxxxxxxx
1
1648547787253