Unix Time in Seconds vs Milliseconds — How to Tell the Difference

One of the most common timestamp bugs: treating a millisecond timestamp as seconds (or the reverse), producing dates that are years off.

Count the digits

Digit countUnitExample
10Seconds1750425600
13Milliseconds1750425600000

Unix time counts seconds since 1970-01-01 00:00:00 UTC. Multiply by 1000 to get milliseconds.

Where each comes from

Seconds — shells, most system APIs, databases, and HTTP headers:

date +%s   # 1750425600

Milliseconds — JavaScript's Date API and most browser timing functions:

Date.now()            // 1750425600000
new Date().getTime()  // 1750425600000
performance.now()     // fractional milliseconds since page load

This mismatch is where bugs hide: JavaScript sends a timestamp to a backend that expects seconds, or vice versa.

Converting in code

// milliseconds → seconds
const sec = Math.floor(Date.now() / 1000);

// seconds → Date object in JS
const d = new Date(sec * 1000);
import time

sec = int(time.time())           # seconds
ms  = int(time.time() * 1000)    # milliseconds
import "time"

sec := time.Now().Unix()      // seconds
ms  := time.Now().UnixMilli() // milliseconds (Go 1.17+)

What goes wrong when you mix them up

  • Pass milliseconds where seconds are expected → you get a date in the year 2,525 or beyond.
  • Pass seconds where milliseconds are expected → you get a date on 1970-01-01 at 00:00:01.

The moment you see a parsed date stuck near 1970 or decades in the future, check the units first — it's almost always a seconds/milliseconds mismatch.

Check quickly

Paste either timestamp into the timestamp converter. It auto-detects whether the value is in seconds or milliseconds and shows you the human-readable equivalent.

For background on Unix time itself, read what is a Unix timestamp or epoch time explained.

Got a config file to check?

Open the config toolkit →