Seconds versus milliseconds
Unix seconds are usually 10 digits for current dates. Unix milliseconds are usually 13 digits. Mixing them up is one of the most common causes of dates that land in 1970 or far in the future.
When you copy a timestamp from JavaScript, it is often milliseconds from Date.now(). When you copy a timestamp from many APIs, databases, or logs, it may be seconds. Always check the expected unit before converting.
- 10 digit current timestamp: usually seconds.
- 13 digit current timestamp: usually milliseconds.
- ISO strings are readable, but still need a timezone assumption.
- UTC is safer for logs, cross-region systems, and scheduled jobs.
const seconds = 1717243200;
const date = new Date(seconds * 1000);
console.log(date.toISOString());
console.log(Math.floor(date.getTime() / 1000));