Epoch Time Converter Excel: How to Convert Unix Time
To convert epoch time (Unix timestamp) in Excel, divide the timestamp by 86400 and add the date 1/1/1970, then format the cell as a date and time. This article explains the exact formulas, common pitfalls, and how to handle milliseconds, time zones, and negative timestamps.
What Is Epoch Time?
Epoch time, also called Unix time or POSIX time, is a system for tracking time as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC) on January 1, 1970. This date is known as the Unix epoch. It is widely used in programming, databases, and file systems because it is a simple integer that is easy to compare and store. For example, the epoch timestamp for 2025-01-01 00:00:00 UTC is 1735689600.
Why Convert Epoch Time in Excel?
Excel does not have a built-in function to convert epoch time directly, so users often need to do it manually. Common scenarios include:
- Importing data from APIs or logs that store timestamps as integers.
- Analyzing server logs or database exports where dates are in epoch format.
- Visualizing time-series data in Excel for reporting or charting.
Without conversion, these numbers are meaningless to most people. Converting them to readable dates makes the data usable for sorting, filtering, and creating charts.
How the Conversion Works
Excel stores dates as serial numbers, where 1 equals January 1, 1900. Each whole number represents a day, and fractions represent time. To convert epoch seconds to an Excel date:
Formula: =A1/86400 + DATE(1970,1,1)
Where:
- A1 is the cell containing the epoch timestamp (in seconds).
- 86400 is the number of seconds in a day (24 hours × 60 minutes × 60 seconds).
- DATE(1970,1,1) is the Excel serial number for the epoch start date.
After entering the formula, format the cell as a date and time (e.g., yyyy-mm-dd hh:mm:ss) to see the result. If the timestamp is in milliseconds, divide by 86400000 instead of 86400.
Step-by-Step Example
Suppose cell A1 contains the epoch timestamp 1735689600 (which is 2025-01-01 00:00:00 UTC).
- In cell B1, enter the formula:
=A1/86400 + DATE(1970,1,1) - Press Enter. Excel will display a serial number like 45658.
- Right-click the cell, choose Format Cells, then select a date and time format such as
yyyy-mm-dd hh:mm:ss. - The result will show
2025-01-01 00:00:00.
If you want to display the time in a specific time zone, add or subtract the offset from UTC. For example, for Eastern Standard Time (UTC-5), use =A1/86400 + DATE(1970,1,1) - 5/24.
Handling Milliseconds and Negative Timestamps
Many systems use epoch timestamps in milliseconds, which are 1000 times larger. To convert those, divide by 86400000:
=A1/86400000 + DATE(1970,1,1)
Negative timestamps represent dates before 1970. The same formula works, but you must ensure the cell format supports dates before 1900. Excel’s default date system starts at 1900, so dates before that may display as a series of # symbols. To handle pre-1970 dates, you can use the 1904 date system (File > Options > Advanced > When calculating this workbook, use the 1904 date system), but this changes the serial numbers for all dates in the workbook.
Common Mistakes and How to Avoid Them
- Forgetting to divide by 86400: If you just add DATE(1970,1,1) to the raw timestamp, you get a huge number, not a date.
- Using the wrong divisor for milliseconds: If your data is in milliseconds and you divide by 86400, the result will be off by a factor of 1000.
- Not formatting the cell as a date: The formula returns a serial number, so you must apply a date format to see the date.
- Ignoring time zones: Epoch time is UTC. If you need local time, adjust the formula by adding or subtracting the offset.
- Using the wrong date system: Excel for Mac may use the 1904 date system by default, which shifts the epoch start date. Check your workbook settings.
Alternatives to Manual Conversion
If you frequently convert epoch time, consider these alternatives:
- Power Query: Use the
From Unix Timetransformation in Power Query (Data > Get Data) to convert epoch columns automatically. - Custom VBA function: Write a simple VBA function to perform the conversion, which can be reused across sheets.
- Online converters: For one-off conversions, many websites offer free epoch converters, but they are not practical for large datasets.
Power Query is especially useful for large datasets because it avoids manual formulas and can refresh automatically.
Frequently Asked Questions
How do I convert epoch time to date in Excel without a formula?
You can use Power Query. In Excel, go to Data > Get Data > From File > From Text/CSV, select your data, then in the Power Query editor, right-click the column and choose Change Type > Using Locale, then select Date or Date/Time. Alternatively, use the ‘From Unix Time’ transformation if available in your version.
Why does my epoch conversion show a #VALUE! error?
This usually happens if the cell contains text or a non-numeric value. Ensure the cell is formatted as a number. Also, check for hidden spaces or commas in the data.
How do I convert epoch time to a date in Excel for Mac?
Excel for Mac uses the 1904 date system by default, so you need to adjust the formula to =A1/86400 + DATE(1970,1,1) - 1462. The number 1462 is the difference in serial numbers between the 1900 and 1904 systems (4 years × 365 days + 1 leap day).
Can I convert epoch time to a date in Excel for free?
Yes, the formulas described here are built into Excel and require no extra software. You can also use Google Sheets, where the same formula works, or free online converters for small tasks.
How do I convert epoch time to local time in Excel?
Add or subtract the time zone offset from UTC. For example, for Pacific Standard Time (UTC-8), use =A1/86400 + DATE(1970,1,1) - 8/24. Remember that daylight saving time may require a different offset.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.