ThisCalculator

Everyday

Epoch Time to Datetime Converter: How It Works

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.

An epoch time to datetime converter takes a Unix timestamp (the number of seconds since January 1, 1970, UTC) and turns it into a human-readable date and time, such as 2025-04-14 09:30:00 UTC. You enter the timestamp (and optionally a time zone), and the converter returns the corresponding calendar date and time, often with the day of the week. This tool is essential for developers, data analysts, and anyone working with logs or APIs that store time as an integer.

Formula

The conversion uses the Unix epoch as the reference point: 00:00:00 UTC on January 1, 1970. The formula is:

Datetime = Epoch Time (seconds) + Epoch Offset

Where:

  • Epoch Time (t) – the input timestamp in seconds (can be negative for dates before 1970).
  • Epoch Offset – 0 for UTC; for local time, add the time zone offset (e.g., +3600 for UTC+1).

The result is a date-time value (year, month, day, hour, minute, second). The converter internally handles leap years, month lengths, and daylight saving time if you select a local zone.

Worked Example

Using the default timestamp 1713089400 (which corresponds to April 14, 2024, 14:10:00 UTC):

  1. Start with the epoch: 1970-01-01 00:00:00 UTC.
  2. Add 1,713,089,400 seconds. Divide by 86,400 (seconds per day) to get days: 19,827.42 days.
  3. Add 19,827 full days to the epoch date: 1970 + 54 years (accounting for leap years) gives 2024-04-14.
  4. The remainder 0.42 days equals 10 hours and 10 minutes, so the time is 14:10:00 UTC.
  5. For UTC output, the result is 2024-04-14 14:10:00. For local (e.g., UTC+2), it becomes 16:10:00.

The converter shows the same result: 2024-04-14 14:10:00 (UTC).

When to Use a Converter

You need an epoch converter when you encounter timestamps in data exports, API responses, or database records. For example, a log file might show 1713089400 and you want to know when that event occurred. It’s also useful when debugging code that uses time() functions, or when comparing timestamps from different systems that use different time zones.

Common Mistakes and How to Avoid Them

  • Mixing seconds and milliseconds: Many systems store time in milliseconds (e.g., 1713089400000). Always check the unit—divide by 1000 if needed.
  • Ignoring time zone: A timestamp is absolute (UTC), but the displayed time depends on the zone. Always specify whether you want UTC or local.
  • Negative timestamps: Dates before 1970 are represented as negative numbers. Ensure your converter handles them correctly.
  • Daylight saving time: When converting to local time, the offset changes twice a year. Use a converter that accounts for this.

How to Choose a Converter

Look for a converter that offers:

  • Support for both seconds and milliseconds.
  • Time zone selection (UTC, local, or specific zones).
  • Reverse conversion (datetime to epoch).
  • Clear display of the day of the week and ISO 8601 format.

Many online converters are free and require no installation. For offline use, you can write a simple script in Python or JavaScript using built-in date functions.

Limitations of the Formula

The Unix epoch system cannot represent dates before 1901 or after 2038 in 32-bit systems (the Year 2038 problem). Most modern systems use 64-bit integers, avoiding this limit. Also, the conversion assumes the Gregorian calendar, which is standard today. Leap seconds are not accounted for in most conversions, as they are irregular and not part of the epoch definition.

Frequently Asked Questions

What is the current epoch time?

You can get it by running date +%s on Linux/macOS, or int(time.time()) in Python. It changes every second.

How do I convert epoch time in Excel?

Divide the timestamp by 86400, add the date 1970-01-01, and format as a date. For milliseconds, divide by 86400000 first.

Why do some timestamps have 10 digits and others 13?

10 digits are seconds since 1970; 13 digits are milliseconds. Always check the source to know which you have.

Can I convert a datetime back to epoch?

Yes, use the reverse formula: subtract the epoch date and multiply by 86400. Most converters offer this option.

Does the converter handle time zones automatically?

It does if you select a time zone. The timestamp itself is always UTC, but the displayed time adjusts to your chosen zone.

What happens if I enter a negative timestamp?

It returns a date before 1970, such as 1969-12-31. Negative timestamps are valid and used for historical data.

Related

Formula used
in t | Timestamp (seconds) | s | 1713089400 | 0
sel tz | Time zone | UTC=0, Local=1 | 0
out dt | Datetime (UTC) | - | t | time
out local | Datetime (Local) | - | t | time

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.