Epoch & Unix Timestamp in JavaScript
Get the current epoch timestamp
const epochSeconds = Math.floor(Date.now() / 1000); Convert epoch to date
const date = new Date(1718200000 * 1000); Convert date to epoch
const epochSeconds = Math.floor(new Date('2026-06-12T00:00:00Z').getTime() / 1000); JavaScript notes
Date.now() and getTime() return milliseconds — the most common source of 13-vs-10-digit bugs. Multiply or divide by 1000 at the boundary.
Check any value live with the epoch converter, or read what Unix time actually counts.
Other languages
C · C# · C++ · Dart · Go · Java · Kotlin · MySQL · Perl · PHP · PostgreSQL · Python · R · Ruby · Rust · Scala · SQLite · Swift · TypeScript