Skip to main content

Convert a Unix timestamp to a date (and a date to a timestamp)

Turn a Unix timestamp into a local date and an ISO 8601 UTC date, or a date and time into a timestamp, with automatic detection of seconds and milliseconds.

  • Clipboard

Embed this widget

Customize the result, check the live preview, then copy the code.

Preview

Embed code type

Code to copy

Responsive and automatically resized by Bethemesh.

Was this tool useful?

How does this tool work?

A Unix timestamp, or epoch time, is the number of seconds elapsed since 1 January 1970 at 00:00 UTC. It is how databases, server logs, APIs and authentication tokens record an instant, with no time zone and no date format. This converter turns a timestamp into a readable date and time, in your time zone and in UTC as ISO 8601, and also works the other way round: it gives the timestamp of a date and time you enter. It recognises millisecond timestamps, used by JavaScript and many APIs, on its own.

A timestamp counts the seconds since the Unix epoch, 1970-01-01T00:00:00Z. POSIX counts every day as exactly 86,400 seconds: leap seconds are ignored, which is why a timestamp converts to a date with plain arithmetic.

Enter a number: from 100,000,000,000 (12 digits) upwards it is read as milliseconds, below that as seconds. The unit used is shown next to the field. The date appears in your device’s time zone, and the exact instant in UTC as ISO 8601.

The other way round, the date and time you enter are interpreted in your device’s time zone, then converted to whole seconds, or to milliseconds if you have just converted a millisecond timestamp.

Negative timestamps are instants before 1970. The supported range is that of JavaScript dates: ±8.64 × 10¹⁵ milliseconds, roughly 270,000 years on either side of 1970.

How to use this tool

  1. Enter a timestamp or a date

    Paste a timestamp in its field, or pick a date and time; the other field updates.

  2. Check the detected unit

    Seconds or milliseconds appear next to the timestamp.

  3. Read the UTC instant

    The ISO 8601 line ends in Z: it is UTC, with no time-zone ambiguity.

  4. Use Now or share

    The button inserts the current timestamp; the calculation link keeps the timestamp you entered.

From timestamp to date

A timestamp is a distance in seconds from the Unix epoch; the date follows from 86,400-second days.

Timestamp in seconds

t = (instant − 1970-01-01T00:00:00Z) in seconds

Days and remainder

days = ⌊t / 86400⌋; seconds of day = t − 86400 × days

Days are counted from 1 January 1970, in UTC.

Milliseconds

t(ms) = 1000 × t(s)

t
Unix timestamp in seconds
86400
seconds in a POSIX day (24 × 60 × 60)

Use cases

Reading a log or a database

Turn a created_at column or a log line into a readable date.

Debugging an API or a token

Check the exp, iat or nbf claims of a JWT, or a date returned by an API, in seconds or milliseconds.

Preparing a query

Get the timestamp of an exact date to filter records or schedule a job.

Comparing local time and UTC

See the local and UTC time of the same instant at a glance, handy for a team spread across time zones.

Examples

A 10-digit timestamp

That is 14 November 2023 at 17:13:20 in New York (UTC−5 in winter). 1,700,000,000 ÷ 86,400 = 19,675 whole days after 1 January 1970, plus 80,000 s, i.e. 22 h 13 min 20 s.

Input

1700000000

Result

2023-11-14T22:13:20.000Z

The same instant in milliseconds

With 13 digits the number is read as milliseconds, giving the same result.

Input

1700000000000

Result

2023-11-14T22:13:20.000Z

The year 2038 problem

This is the largest signed 32-bit integer. A system that stores timestamps in 32 bits overflows one second later.

Input

2147483647

Result

2038-01-19T03:14:07.000Z

Before 1970

A negative timestamp counts back from the epoch: −86,400 s is one day earlier.

Input

-86400

Result

1969-12-31T00:00:00.000Z

Tips and best practices

  • 10 digits: seconds (until the year 2286); 13 digits: milliseconds. A millisecond timestamp from before March 1973 has fewer than 12 digits and would be read as seconds.
  • A timestamp holds no time zone: it is always a UTC instant. Only its display depends on the zone.
  • The swap button only changes the order of the fields; conversion works in both directions at any time.
  • To display a date in another time zone than yours, use the time zone converter.
  • A timestamp in seconds drops the milliseconds: 12:00:00.999 gives the same value as 12:00:00.

Sources and references

Frequently asked questions

What is a Unix timestamp?

The number of seconds since 1 January 1970 at 00:00:00 UTC, known as the Unix epoch. It is defined by the POSIX standard and used by most computer systems.

How can I tell whether a timestamp is in seconds or milliseconds?

Count the digits: today, 10 for seconds and 13 for milliseconds. The tool treats any number of at least 100,000,000,000 as milliseconds.

Does a Unix timestamp include leap seconds?

No. POSIX counts every day as 86,400 seconds, and JavaScript also ignores leap seconds. That is what makes an exact conversion by arithmetic possible.

Why does the displayed time differ from UTC?

The date field uses your device’s time zone, including daylight saving time. The ISO 8601 line gives the same instant in UTC.

What is the year 2038 problem?

Systems that store timestamps in a signed 32-bit integer cannot go past 2,147,483,647, which is 19 January 2038 at 03:14:07 UTC. 64-bit systems are not affected.

Can I convert a date before 1970?

Yes. The timestamp becomes negative: 31 December 1969 at 00:00 UTC is −86,400.

What happens with a local time skipped by a clock change?

When clocks go forward, a local time such as 2:30 does not exist. The browser shifts it; check the UTC line to see which instant was actually used.

Related tools

Tools similar or complementary to this one.

Similar tools

Convert a date and time from one time zone to another, daylight saving time included.

Dates & timeFeaturedUse this tool

Express the gap between two date-times as “3 days ago” or “in 2 hours”.

Dates & timeUse this tool
GuideBest practicesIntermediate

Time zones and meetings: avoid offset mistakes

Convert times between countries, understand daylight saving time and find international meeting slots without mental arithmetic.

7 September 20262 min