- Published on
- Ashik Nesin
Date object has getTime() method and it returns number of milliseconds since the Unix epoch which is January 1, 1970 00:00:00 UTC
And unix timestamp are mostly represented in
milliseconds and so we'll be converting milliseconds to seconds by dividing it by 1000.
const date = new Date(); // Or any Date('YYYY-MM-DD') const unixTimestamp = Math.floor(date.getTime() / 1000);
Happy converting date!