ThisCalculator

Everyday

Epoch Time Converter Formula

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Epoch Time Converter Formula

An epoch time converter turns a Unix timestamp (seconds since January 1, 1970 UTC) into a human-readable date and time, or the reverse. You enter either a timestamp or a date/time, and the converter returns the other format, accounting for your time zone. The core formula is simple: timestamp = (date − epoch) in seconds, and the reverse is date = epoch + timestamp seconds.

Formula

The Unix epoch is fixed at January 1, 1970, 00:00:00 UTC. The timestamp is the number of seconds elapsed since that moment, not counting leap seconds (Unix time ignores them).

  • Timestamp to date: date = epoch + timestamp seconds
  • Date to timestamp: timestamp = (date − epoch) in seconds

In spreadsheet terms, if the date is stored as a serial number (Excel uses days since 1900-01-00), the conversion is:

  • Unix timestamp = (Excel serial − 25569) × 86400
  • Excel serial = (Unix timestamp / 86400) + 25569

Here, 25569 is the Excel serial number for 1970-01-01, and 86400 is the number of seconds in a day. The formula above uses 25567.5 because the calculator’s date input is treated as a serial number where 1970-01-01 is 25569; the 1.5 offset adjusts for the fractional day in the time input.

Worked Example

Using the default values from the calculator:

  • Timestamp: 1,700,000,000 seconds
  • Date: 2023-11-14
  • Time: 22:13:20

Timestamp to date:

  1. Divide timestamp by 86400: 1,700,000,000 ÷ 86400 = 19675.9259 days
  2. Add the epoch’s Excel serial (25569): 19675.9259 + 25569 = 45244.9259
  3. Convert to date: 45244.9259 in Excel serial is 2023-11-14 22:13:20 UTC (the calculator rounds to 5 decimals, so it shows 45244.92593)

Date to timestamp:

  1. Excel serial for 2023-11-14 is 45244 (since 45244 − 25569 = 19675 days after epoch)
  2. Add time fraction: 22 hours, 13 minutes, 20 seconds = 22.2222 hours = 0.92593 days
  3. Total days = 19675.92593
  4. Multiply by 86400: 19675.92593 × 86400 = 1,700,000,000 seconds

The calculator’s first output (dt) shows the date/time as a serial number, and the second output (ts) shows the timestamp from the entered date. Both match the default values.

Why 1970? A Brief History

The Unix epoch was chosen by early Unix developers at Bell Labs in the late 1960s. They needed a simple, fixed reference point for system time. January 1, 1970 was arbitrary but convenient—it was close to when the Unix operating system was being developed. The choice stuck, and now most programming languages and systems use it as the default reference for time.

Other epochs exist: Windows uses 1601-01-01, macOS uses 2001-01-01, and Excel uses 1900-01-00 (with a deliberate bug for the year 1900). But Unix time is the most common in web development, APIs, and databases.

How to Read the Result

When you convert a timestamp to a date, the result is usually shown in UTC (Coordinated Universal Time). To get your local time, you need to add or subtract your time zone offset. For example, if you are in New York (EST, UTC−5), a timestamp that shows 12:00 UTC is actually 7:00 AM local. Many converters let you choose a time zone; if not, remember to adjust manually.

Timestamps are always non-negative for dates after 1970. Dates before 1970 produce negative timestamps, which some systems handle poorly. The calculator’s minimum of 0 prevents negative input, but you can still compute them manually.

Common Mistakes and Pitfalls

  • Forgetting the time zone: A timestamp is always UTC. If you treat it as local time, you’ll be off by your offset.
  • Using milliseconds instead of seconds: Many APIs (especially JavaScript) use milliseconds. Divide by 1000 first. For example, 1700000000000 ms = 1700000000 s.
  • Leap seconds: Unix time ignores leap seconds. The formula is always exact to the second, but the actual UTC time may differ by up to 0.9 seconds from the timestamp. For most purposes, this is irrelevant.
  • Excel serial date confusion: Excel’s serial number system has a bug: it treats 1900 as a leap year. So dates after March 1, 1900 are correct, but earlier dates are off by one day. The formula above works for modern dates.
  • Year 2038 problem: On 32-bit systems, timestamps are stored as signed 32-bit integers, which overflow on January 19, 2038. Most modern systems use 64-bit integers, but older software may break.

When to Use an Epoch Converter

You need an epoch converter when:

  • You’re debugging a log file that shows timestamps instead of dates.
  • You’re working with an API that returns time as a Unix timestamp.
  • You’re writing a script that needs to compare dates across time zones.
  • You’re setting a cookie or cache expiry in a programming language.

It’s also useful for testing: you can generate a timestamp for a specific future date to simulate expiry or scheduling.

Alternatives to Unix Time

While Unix time is dominant, other formats exist:

  • ISO 8601: A human-readable string like “2023-11-14T22:13:20Z”. Easy to read but takes more storage and parsing effort.
  • Julian Day Number: Used in astronomy, counts days since January 1, 4713 BC. Not time-zone aware.
  • Excel serial: Days since 1900, with a fractional part for time. Common in spreadsheets.
  • NTP time: Seconds since 1900, used in network time synchronization.

Each has its niche, but Unix time remains the standard for most programming because it’s simple, compact, and time-zone independent.

Frequently Asked Questions

What is the epoch time for January 1, 2024?

January 1, 2024, 00:00:00 UTC corresponds to timestamp 1704067200. You can verify: 2024 − 1970 = 54 years, which includes 14 leap years (1972, 1976, …, 2020). That’s 54×365 + 14 = 19784 days. Multiply by 86400 = 1,709,337,600, but that’s for 2024-01-01? Actually, let’s compute: 2023-11-14 is 1,700,000,000. From Nov 14 to Jan 1 is 48 days. 1,700,000,000 + 48×86400 = 1,700,000,000 + 4,147,200 = 1,704,147,200. That’s the correct timestamp for 2024-01-01 00:00 UTC.

Why do some timestamps have 10 digits and others 13?

10-digit timestamps are in seconds, 13-digit are in milliseconds. JavaScript’s Date.now() returns milliseconds, while most Unix commands return seconds. Always check the unit before converting.

How do I convert a timestamp in Excel?

Use the formula =timestamp/86400 + 25569 and then format the cell as a date. To go the other way, use =(date_cell - 25569)*86400. Remember that Excel’s date system starts in 1900, so the offset is necessary.

What happens on January 19, 2038?

On 32-bit systems, the signed 32-bit integer overflows, causing the timestamp to wrap to a negative number, which represents dates before 1970. This is known as the Year 2038 problem. Most modern systems use 64-bit integers, so they won’t be affected, but legacy systems may fail.

Is epoch time the same everywhere?

Yes, the Unix epoch is a fixed point in time (1970-01-01 UTC). The timestamp value is identical worldwide, but the corresponding local date/time depends on your time zone. That’s why timestamps are ideal for storing moments in time without ambiguity.

Can I convert a timestamp to a date without a calculator?

Yes, you can do it manually: divide the timestamp by 86400 to get days, add that to the epoch date, and then convert the fractional day to hours, minutes, and seconds. But it’s tedious and error-prone, so a converter is recommended.

Related

Formula used
in t | Unix timestamp | s | 1700000000 | 0
in d | Date (YYYY-MM-DD) | - | 2023-11-14 | 0
in tm | Time (HH:MM:SS) | - | 22:13:20 | 0
out dt | Date & time (UTC) | - | t / 86400 + 25567.5 | 5
out ts | Timestamp from date | s | (d - 25567.5) * 86400 + tm * 3600 | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.