ThisCalculator

Everyday

Human Readable Time to Epoch Converter

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.

This calculator converts a human-readable date and time (like “2025-04-09 14:30:00”) into a Unix epoch timestamp (the number of seconds since January 1, 1970, UTC), and also converts an epoch timestamp back into a readable date and time. You enter either the date/time or the epoch number, and you get the corresponding value in the other format, accounting for your timezone offset.

Formula

The conversion uses the definition of Unix time: the number of seconds that have elapsed since 00:00:00 UTC on 1 January 1970, not counting leap seconds. For a given date and time in a specific timezone, the epoch is calculated as:

epoch = (days_from_1970_to_date × 86400) + (seconds_from_midnight) – (timezone_offset_hours × 3600)

Where:

  • days_from_1970_to_date – the number of days between 1970-01-01 and the given date (using a proleptic Gregorian calendar).
  • seconds_from_midnight – hours × 3600 + minutes × 60 + seconds.
  • timezone_offset_hours – the offset of the given timezone from UTC (e.g., 0 for UTC, +5 for EST, -8 for PST).

Conversely, to convert an epoch to a readable date, you divide the epoch by 86400 to get days, add the remainder as seconds, and then convert those to a calendar date and time, again applying the timezone offset.

Worked Example

Using the default values: date = 2025-04-09 14:30:00, timezone offset = 0 (UTC).

  1. Days from 1970-01-01 to 2025-04-09: 20187 days (calculated via standard date arithmetic).
  2. Seconds from midnight: 14×3600 + 30×60 + 0 = 50400 + 1800 = 52200 seconds.
  3. Total seconds = 20187 × 86400 + 52200 = 1,744,156,800 + 52,200 = 1,744,209,000.
  4. Since timezone offset is 0, no adjustment is needed.

So the epoch is 1744209000 (the calculator rounds to 0 decimals, giving 1744209000).

What Is Unix Time?

Unix time (also called POSIX time or Epoch time) is a system for describing instants in time as the number of seconds that have elapsed since 00:00:00 UTC on Thursday, 1 January 1970. This date is known as the Unix epoch. It is used widely in programming, operating systems, and file systems because it is a simple integer that is easy to store and compare.

One important detail: Unix time counts seconds, but it does not include leap seconds. Leap seconds are added occasionally to keep atomic time in sync with Earth’s rotation, but Unix time ignores them, so a Unix timestamp can be off by a few seconds from actual UTC during a leap second. For most practical purposes, this is irrelevant.

How the Conversion Works

The conversion between a human-readable date and an epoch timestamp is straightforward but requires careful handling of timezones. The key steps are:

  • Parse the date and time into its components (year, month, day, hour, minute, second).
  • Calculate the number of days from the epoch to that date, using a formula that accounts for leap years.
  • Multiply days by 86400 (seconds per day) and add the seconds from the time component.
  • Adjust for the timezone offset: if the input time is in UTC+5, subtract 5×3600 seconds to get the UTC equivalent.

For the reverse, you divide the epoch by 86400 to get days, then convert the remainder to hours, minutes, and seconds, and then convert the days to a calendar date (again accounting for leap years).

Why Use an Epoch Converter?

Developers and system administrators frequently need to convert between human-readable timestamps and epoch values. Common scenarios include:

  • Debugging logs that display timestamps in epoch format.
  • Writing scripts that need to compare or manipulate dates.
  • Setting file timestamps or scheduling tasks using epoch values.
  • Interpreting data from APIs that return epoch timestamps.

An online converter is handy because you can quickly verify a value without writing code. However, most programming languages have built-in functions (e.g., date() in PHP, datetime in Python, Date.now() in JavaScript) that do the same thing.

Common Mistakes and Pitfalls

When converting between human-readable time and epoch, several common errors can occur:

  • Timezone mix-ups: Forgetting to apply the timezone offset is the most frequent mistake. An epoch is always UTC, so if you input a local time without specifying the offset, the result will be off by the timezone difference.
  • Leap year miscalculation: The day count must include leap years correctly. A simple formula that assumes 365 days per year will be wrong for dates after February 28 in any leap year.
  • Date format confusion: Some systems use month/day/year, others use day/month/year. Always verify the input format.
  • Milliseconds vs. seconds: Many systems (like JavaScript’s Date.now()) return milliseconds, not seconds. If you divide by 1000 incorrectly, you’ll get a date far in the future or past.

To avoid these, always double-check the timezone and the unit (seconds vs. milliseconds).

Choosing the Right Converter

There are many epoch converters available online, but they differ in features. When choosing one, consider:

  • Timezone support: Does it let you specify a timezone offset? This is essential for accuracy.
  • Bidirectional conversion: Can it convert both ways (date to epoch and epoch to date)?
  • Precision: Does it handle milliseconds or microseconds? Some tools only work with seconds.
  • Batch conversion: Some converters allow you to convert multiple timestamps at once, which is useful for logs.

For a quick one-off calculation, a simple online tool like this one is sufficient. For programming, you’ll likely use built-in functions instead.

Limitations of the Formula

The conversion formula assumes a proleptic Gregorian calendar, which extends the current calendar backward indefinitely. This is standard for Unix time, but it means that dates before 1582 (when the Gregorian calendar was introduced) may not match historical records. Also, the formula does not account for timezone changes due to daylight saving time (DST) unless you manually adjust the offset. If you input a date in a DST-affected timezone, you must know the correct offset for that specific date.

Finally, the formula uses integer arithmetic, so it cannot represent fractional seconds. For sub-second precision, you would need to use milliseconds or microseconds, which are separate units.

Frequently Asked Questions

What is the Unix epoch?

The Unix epoch is 00:00:00 UTC on 1 January 1970. It is the reference point for Unix time, which counts the number of seconds since that moment.

Why is 1970 used as the start?

1970 was chosen because it was the approximate time when Unix was being developed at Bell Labs. It was a round, early date that made calculations simple, and it was already in use in early Unix systems.

What is the difference between epoch seconds and milliseconds?

Epoch seconds are the number of seconds since the epoch, while epoch milliseconds are the number of milliseconds (1/1000 of a second). Many programming languages (like JavaScript) use milliseconds by default, so you often need to divide by 1000 to get seconds.

How do I convert a local time to epoch if I don’t know the timezone offset?

You need to know the timezone offset for that date and location. If you don’t, you can use a timezone database (like IANA time zones) to find the correct offset, which may change due to DST. Most programming languages have built-in functions that handle this automatically.

Can epoch time be negative?

Yes, epoch time can be negative for dates before 1970. For example, 1969-12-31 23:59:59 UTC is -1. Negative timestamps are valid and used in some systems.

Does the converter account for leap seconds?

No, Unix time ignores leap seconds. This means that during a leap second, the Unix timestamp does not change, and the actual UTC time may be slightly ahead. For most applications, this is acceptable.

Related

Formula used
in t | Date and time (YYYY-MM-DD HH:MM:SS) | - | 2025-04-09 14:30:00 | 0
in e | Epoch seconds | - | 1744205400 | 0
in z | Timezone offset from UTC (hours) | - | 0 | -12
out epoch | Epoch timestamp (seconds) | - | e | 0
out readable | Readable date/time (UTC) | - | t | 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.