EN
TypeScript - get UNIX timestamp in seconds
0
points
In this short article, we would like to show how to get unix timstamp in seconds in TypeScript.
Note: as unix timestamp in this article we understans bash
date +%scommand result.
Quick solution:
const getTimestamp = (): number => {
const now = Date.now();
return Math.floor(0.001 * now);
};
// Usage example:
const now: number = getTimestamp();
console.log(now);
Example output:
1648547546