⏱️ TimestampEasy

Home → Unix Timestamp: Seconds vs Milliseconds

Unix Timestamp: Seconds vs Milliseconds

The difference between Unix seconds and Unix milliseconds is simple mathematically but responsible for many real-world timestamp bugs. Both represent the same kind of instant, but one second contains 1,000 milliseconds.

UnitMultiplier from secondsCommon example
Seconds11767225600
Milliseconds1,0001767225600000

How to convert

Seconds to milliseconds: multiply by 1,000. Milliseconds to seconds: divide by 1,000. If the target system expects whole seconds, decide whether to floor, round or reject fractional values rather than silently losing precision.

milliseconds = seconds * 1000
seconds = milliseconds / 1000

Where each unit appears

Do not guess only from digit count

A 10-digit number often looks like Unix seconds today, and a 13-digit number often looks like Unix milliseconds. But older or future dates can have different lengths, and custom data can be formatted differently. Documentation is the reliable source of truth.

Debugging a 1,000× error

If a converted date is thousands of times too far into the past or future, check the unit first. Normalizing both values to milliseconds or both to seconds before comparison usually reveals the issue quickly.

Related Timestamp Tools

Choosing Seconds or Milliseconds in Real Applications

Seconds and milliseconds are both common timestamp units, but mixing them is one of the easiest ways to create a date that looks absurdly wrong. A good system treats the unit as part of the data contract. If a database column, API field, or event stream says 'Unix milliseconds', every consumer should interpret it in that same unit until an explicit conversion is made.

A safe conversion rule

To convert whole Unix seconds to milliseconds, multiply by 1,000. To convert milliseconds to Unix seconds, divide by 1,000, deciding what to do with any fractional remainder. Do not repeatedly convert the same value as it passes through multiple services; keep one canonical unit at the boundary and adapt only for libraries that require another representation.

Quick reference

UnitScaleCommon examples
Seconds1,000 msUnix/POSIX timestamps, many APIs
Milliseconds1 msJavaScript Date, browser timestamps
Microseconds0.001 msHigh-precision event data
Nanoseconds0.000001 msSome telemetry and systems code

Practical checks

Frequently Asked Questions: Practical Details

Why do JavaScript and Unix examples often use different digit lengths?

JavaScript commonly uses milliseconds while traditional Unix examples often use seconds.

Should I always convert everything to milliseconds?

No. Use the unit defined by the system boundary and convert only when the target library needs a different unit.

What is the fastest way to spot a unit bug?

Compare the value with a known recent date and check whether it differs by roughly 1,000× from the expected representation.

Frequently Asked Questions

How many milliseconds are in one second?

Exactly 1,000 milliseconds.

Does JavaScript use seconds or milliseconds?

The JavaScript Date constructor and Date.now() commonly use milliseconds since the Unix Epoch.

Why does my timestamp produce a wildly wrong date?

A seconds/milliseconds mismatch is one of the most common causes.