Time, Date, Navigation & Astronomy Calendar Systems & Timestamps POSIX.1-2017 seconds since the Epoch

Unix Timestamp Converter Calculator

Paste an epoch value and get the UTC date, your local date, the ISO 8601 string and the day of the week; or switch direction and turn a calendar date into a timestamp. Seconds, milliseconds and microseconds are all handled, and the calculator flags the two mistakes that account for nearly every wrong answer — a millisecond value read as seconds, and a date past the 2038 limit of signed 32-bit time. The arithmetic is plain integer division, and every step is shown.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
DirectionChoose which way round you are converting; only the fields you need stay visible.Timestamp → date
TimestampThe raw epoch value exactly as it appears in your log, database column or API payload.1750000000
Timestamp unitTen digits is normally seconds, thirteen milliseconds and sixteen microseconds for present-day dates.Seconds
YearFour-digit year; years before 1970 give negative timestamps.2026
MonthMonth number, 1 for January through 12 for December.6
DayDay of the month.15
HourHour on a 24-hour clock in the zone given by the offset below.12
MinuteMinutes past the hour.0
SecondSeconds past the minute.0
Your UTC offsetUsed to interpret the date you type in and to display the local line; leave at 0 to work purely in UTC.0 h

It returns

  • Unix timestamp (seconds) — Seconds since 1970-01-01T00:00:00Z, ignoring leap seconds.
  • UTC date and time
  • Local date and time — The same instant shifted by the UTC offset you entered.
  • ISO 8601 string
  • Day of the week (UTC)
  • Unix timestamp (milliseconds)
  • Whole days since the epoch

The formula

t=86400N+3600h+60m+s3600Z
w=((Nmod7)+4)mod7

In plain text: t = 86400 × days(Y, M, D) + 3600h + 60m + s − 3600 × offset; inverse: days = ⌊t/86400⌋, secondsOfDay = t − 86400 × days

  • tUnix timestamp: seconds since 1970-01-01T00:00:00Z (s)
  • NWhole days from 1970-01-01 to the date, negative before the epoch (days)
  • h, m, sHour, minute and second of the local clock reading (h, min, s)
  • ZUTC offset of that reading (hours)

POSIX time counts every day as exactly 86,400 seconds and therefore ignores leap seconds. That makes the mapping between a timestamp and a UTC calendar date exact and reversible, at the cost of the timestamp not being a true count of elapsed SI seconds.

Updated Category Calendar Systems & Timestamps Verified against published test cases Reading time 10 min

What a Unix timestamp actually is

A Unix timestamp is a single integer: the number of seconds that have elapsed since 1970-01-01T00:00:00Z, called the Epoch. Nothing else is encoded in it. There is no time zone, no calendar, no daylight saving rule and no ambiguity, which is exactly why it is the representation almost every database, log format and API uses internally.

The reason it works so well is that comparison and subtraction become plain arithmetic. Deciding whether one event preceded another is an integer comparison. The gap between two events is one subtraction. Neither operation has to know that February has a variable length or that a country moved its clocks. Every complication in civil timekeeping lives in the conversion at the edges, and this calculator is that conversion.

POSIX defines the value formally as “seconds since the Epoch” computed from a UTC calendar date by an expression that treats every day as exactly 86,400 seconds. That definition has a consequence people find surprising: because UTC has occasionally inserted a leap second, a Unix timestamp is not a true count of elapsed SI seconds since 1970. It is a count of the days-and-seconds you would read off a UTC calendar. As of the last insertion in December 2016, the accumulated difference is 27 seconds. The trade-off is deliberate — the mapping between timestamps and calendar dates stays exact and reversible, which matters more for almost every application than 27 seconds do.

Some systems store finer units. JavaScript, Java and most JSON APIs use milliseconds; Python's time.time_ns, PostgreSQL and many tracing systems use microseconds or nanoseconds. The count is the same, scaled, and the unit selector here divides it back down before anything else happens.

The formula, one variable at a time

Going from a date to a timestamp is t = 86400N + 3600h + 60m + s − 3600Z, where N is the count of whole days from 1970-01-01 to your date. The offset term Z is subtracted because a local clock reading is ahead of UTC by its offset; a 09:00 reading at UTC+5:30 is 03:30 UTC, five and a half hours earlier.

Computing N is the only non-obvious part, because it has to respect the Gregorian leap rule — leap years are those divisible by 4, except centuries not divisible by 400. This calculator uses a closed-form days-from-civil algorithm that shifts the year to start in March, so the leap day falls at the end of the cycle and no special case is needed. It is exact for any year, including before the epoch, where N is negative. The leap year calculator explains the rule itself in detail.

The inverse is two floor operations. days = ⌊t/86400⌋, and seconds-of-day is the remainder t − 86400 × days. Using a true floor rather than truncation matters: for negative timestamps, truncating toward zero puts the seconds-of-day negative and shifts the date by a day. That is a real and common off-by-one bug in hand-rolled date code.

Day of week falls out for free. 1970-01-01 was a Thursday, so the index is ((days mod 7) + 4) mod 7 with 0 meaning Sunday. Because the epoch anchors it, no separate calendar rule is needed — which is one reason the day of week calculator and this one always agree.

Worked example: decoding the timestamp 1,000,000,000

The billionth second of the epoch was noted at the time by Unix users; here is how you get its date from the integer alone.

  1. Whole days. ⌊1,000,000,000 / 86,400⌋ = ⌊11,574.074⌋ = 11,574 days.
  2. Seconds accounted for by those days. 11,574 × 86,400 = 999,993,600 s.
  3. Seconds within the final day. 1,000,000,000 − 999,993,600 = 6,400 s.
  4. Hour. ⌊6,400 / 3,600⌋ = 1, using 3,600 s.
  5. Minute. ⌊(6,400 − 3,600) / 60⌋ = ⌊2,800 / 60⌋ = 46, using 2,760 s.
  6. Second. 2,800 − 2,760 = 40. So the time of day is 01:46:40 UTC.
  7. Date. Converting 11,574 days after 1970-01-01 through the Gregorian rule gives 2001-09-09.
  8. Day of week. 11,574 mod 7 = 3, so (3 + 4) mod 7 = 0, which is Sunday.

The full ISO 8601 form is 2001-09-09T01:46:40Z. Reverse the calculation to check: 11,574 × 86,400 + 1 × 3,600 + 46 × 60 + 40 = 999,993,600 + 3,600 + 2,760 + 40 = 1,000,000,000. In milliseconds the same instant is 1,000,000,000,000 — three more digits, same moment.

Landmark epoch values

Useful anchors for eyeballing whether a timestamp is plausible before you convert it. Every row is UTC.
Timestamp (s)UTC date and timeDayDays since epoch
−2,147,483,6481901-12-13 20:45:52Friday−24,856
−11969-12-31 23:59:59Wednesday−1
01970-01-01 00:00:00Thursday0
946,684,8002000-01-01 00:00:00Saturday10,957
1,000,000,0002001-09-09 01:46:40Sunday11,574
1,234,567,8902009-02-13 23:31:30Friday14,288
1,500,000,0002017-07-14 02:40:00Friday17,361
1,704,067,2002024-01-01 00:00:00Monday19,723
2,000,000,0002033-05-18 03:33:20Wednesday23,148
2,147,483,6472038-01-19 03:14:07Tuesday24,855

Each row is ⌊t/86400⌋ days plus the remainder as seconds of day, converted through the Gregorian calendar. The first and last rows are the signed 32-bit limits.

How to read the result

Start with the digit count, because it identifies the unit faster than anything else. For dates in the 2020s and 2030s a seconds timestamp has ten digits, milliseconds thirteen and microseconds sixteen. A ten-digit value read as milliseconds lands in January 1970, and a thirteen-digit value read as seconds lands tens of thousands of years in the future — both are unmistakable once you know to look, and the calculator warns when the magnitude and the selected unit disagree.

The UTC line is the authoritative one. The local line is only as good as the offset you typed, and it applies a fixed offset rather than a zone rule, so it will be an hour out if the date falls on the other side of a daylight saving transition from the offset you gave. Convert with the time zone converter when the zone rule matters.

A negative timestamp is legitimate and denotes an instant before 1970. Support for negative values is uneven in practice — some database drivers and embedded libraries clamp them at zero — so if you are storing historical dates, test the round trip rather than assuming it works. Astronomical and historical work is usually better served by a Julian date, which has no such discontinuity.

Values above 2,147,483,647 are past the range of signed 32-bit time_t. Sixty-four-bit systems are unaffected, but embedded devices, old file formats and some network protocols still carry 32-bit fields, and they wrap to December 1901 rather than failing loudly. If you are testing date handling, 2038-01-19T03:14:07Z and the second after it are the two values to try.

Mistakes that produce a wrong date

  • Reading milliseconds as seconds. The single most common epoch bug. A JavaScript Date.now() value divided by nothing lands your date around the year 56,000.
  • Truncating instead of flooring for negative timestamps. Truncation toward zero produces a negative seconds-of-day and shifts pre-1970 dates by one day.
  • Assuming the timestamp carries a time zone. It does not. Any local time you display is a rendering decision made downstream, not a property of the value.
  • Treating the difference of two timestamps as elapsed SI seconds. Across a leap second insertion it is short by one second, because POSIX time skips them.
  • Applying a fixed offset across a daylight saving boundary. The offset you enter is used verbatim; the real zone may have used a different one on that date.
  • Storing a timestamp in a 32-bit column. It works until 2038-01-19 and then silently wraps to 1901 rather than raising an error.

POSIX.1-2017 and the definition of “seconds since the Epoch”

The POSIX standard (IEEE Std 1003.1-2017) defines the relationship between a timestamp and a UTC calendar date by an explicit expression that counts 86,400 seconds per day, 31,536,000 seconds per non-leap year, plus a day for each leap year in between. It states directly that the value does not necessarily equal the number of seconds actually elapsed, because leap seconds are excluded. ISO 8601 governs the textual form — 2001-09-09T01:46:40Z, where the trailing Z means UTC — and RFC 3339 profiles it for internet protocols, which is the form most APIs emit.

Use epoch seconds for anything a machine will compare or subtract. Use ISO 8601 for anything a human or another system will read, because it is unambiguous, sorts lexicographically in the same order as chronologically, and carries the offset explicitly. Keep the two in step by treating the timestamp as the stored value and the string as a rendering.

For calendar-level questions the arithmetic is easier elsewhere: the day of year calculator gives the ordinal date, the ISO week number calculator gives the week, and the age in days calculator counts days between two dates without going through seconds at all. Astronomers use the Julian date, a continuous day count from 4713 BC with no epoch discontinuity, which is why observation logs and ephemerides use it rather than epoch seconds.

If you need elapsed physical time rather than calendar time — for interval measurement, benchmarking or spacecraft navigation — use a monotonic clock or International Atomic Time (TAI) instead. TAI counts real SI seconds without interruption and currently runs 37 seconds ahead of UTC. A Unix timestamp difference is close enough for almost everything, and wrong by one second per intervening leap second when it is not.

Frequently asked questions

What is the Unix epoch?

It is 1970-01-01T00:00:00Z, the zero point from which Unix timestamps count. The date was chosen for convenience when early Unix systems were being built and has no astronomical or legal significance. Instants before it are represented by negative numbers, so −1 is 1969-12-31T23:59:59Z.

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

Count the digits. For current dates a seconds value has ten digits, milliseconds thirteen and microseconds sixteen. A quicker test is to convert both ways: if one reading lands in 1970 and the other in the present, you have your answer. The calculator warns automatically when the magnitude and the selected unit disagree.

What happens in 2038?

Signed 32-bit time_t overflows at 2,147,483,647 seconds, which is 2038-01-19T03:14:07Z, and wraps to 1901-12-13T20:45:52Z. Sixty-four-bit systems are unaffected and will remain so for roughly 292 billion years. The remaining exposure is in embedded firmware, old file formats and protocol fields that still carry 32-bit time.

Do Unix timestamps include leap seconds?

No. POSIX defines every day as exactly 86,400 seconds, so a leap second is not counted and the timestamp repeats or is stretched depending on how the system handles it. As a result the difference between two timestamps is short by one second for each leap second between them — 27 in total since 1972. Use TAI or a monotonic clock if you need true elapsed seconds.

What time zone is a Unix timestamp in?

None. It is an absolute count of seconds from a UTC-defined instant, so it carries no zone at all. Any local time you see has been produced by applying an offset at display time. That is precisely why systems store timestamps rather than local strings — the zone can be chosen per user without the stored value changing.

How do I convert a timestamp in a spreadsheet?

Divide by 86,400 and add the serial number of the epoch date: in Excel and Google Sheets that is =t/86400 + DATE(1970,1,1), then format the cell as a date and time. Going the other way, subtract the epoch date and multiply by 86,400. Spreadsheets store dates as days rather than seconds, which is the whole of the difference.

Why does my pre-1970 date come out one day early?

Almost always because the code truncated the division toward zero instead of flooring it. For −100,000 seconds, truncation gives −1 day with a remainder of −13,600 seconds, which is not a valid time of day; flooring gives −2 days with a remainder of 72,800 seconds, which is correct. This calculator floors.

What is the largest date this handles?

Values up to about 8.64 × 1015 seconds are accepted, which is roughly 273 million years either side of the epoch and matches the safe range of double-precision millisecond arithmetic. Well before that, the Gregorian calendar itself stops being meaningful — it was only introduced in 1582, and this calculator projects it backwards proleptically.

References