Two common units

Unix time counts from the Unix epoch. Many backend systems use whole seconds, while JavaScript Date and several client APIs use milliseconds. A current seconds value commonly has ten digits; milliseconds commonly has thirteen.

Digit length is a useful clue, not a permanent specification. APIs should document units explicitly.

The classic conversion bug

Passing seconds directly into a milliseconds API produces a date near January 1970. Passing milliseconds into a seconds-based system can produce a date far in the future or exceed numeric limits.

Convert deliberately at boundaries and name values with unit suffixes such as createdAtMs or expiresAtSeconds.

Timezone is separate

A Unix timestamp represents an instant. Timezone only affects how that instant is displayed. Store instants in a consistent representation and convert for people at the presentation layer.

Safer interfaces

Use ISO 8601 strings when human readability and interoperability are important, include an explicit offset, validate plausible ranges, and test boundary cases around daylight-saving changes and date parsing.

Use the related calculator

Turn the concepts in this guide into a practical estimate with DevCalc’s free browser-based tools.

Open related tools →