Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Epoch to Datetime: Convert Unix Time

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To convert an epoch (Unix) timestamp to a readable date and time in Excel, divide the number by 86,400 and add the date 1 January 1970, then format the result as a date/time. For a timestamp in cell A2, the formula is =A2/86400+DATE(1970,1,1). That works because Unix time counts seconds from midnight UTC on 1 January 1970, and Excel stores dates as whole days since 1 January 1900, so dividing seconds by the 86,400 seconds in a day turns them into Excel days.

This guide covers the standard conversion for whole seconds, how to handle milliseconds, how to adjust for your local time zone, and what to check when the result looks wrong. It applies to Excel for Microsoft 365 and Excel 2019/2021 on Windows and Mac; the same formulas work in Excel for the web, and the menu labels can differ slightly by version and region.

What You'll Need

  • Excel for Microsoft 365, Excel 2019/2021, or Excel for the web (the formulas also work in older versions).
  • Your epoch values in a column, with no thousands separators or text formatting. A value like 1700000000 should be a number, not text.
  • Knowledge of whether your timestamps are in seconds or milliseconds, and which time zone you want the result in.

Step-by-Step

  1. Check the data type. Click a timestamp cell and look at the formula bar. If the number is left-aligned, it is probably stored as text. Select the column, then use Data > Text to Columns and click Finish to convert it to numbers. Alternatively, multiply by 1 in a helper column: =A2*1.
  2. Confirm the unit. A 10-digit number (for example 1700000000) is in seconds. A 13-digit number (for example 1700000000000) is in milliseconds. If your values are 13 digits, you must divide by 86,400,000 instead of 86,400.
  3. Enter the base formula. In an empty column next to your data, type =A2/86400+DATE(1970,1,1) and press Enter. Replace A2 with the first timestamp cell. This returns an Excel serial number that represents the date and time.
  4. Format the result as a date/time. Select the formula cell, press Ctrl+1 (Cmd+1 on Mac) to open Format Cells, choose Date or Custom, and pick a format such as yyyy-mm-dd hh:mm:ss. Without this step the cell shows a decimal number, which is correct but not readable.
  5. Handle milliseconds. If your timestamps are 13 digits, use =A2/86400000+DATE(1970,1,1). If you prefer to divide by 86,400 and then by 1,000, wrap it as =(A2/1000)/86400+DATE(1970,1,1).
  6. Adjust for your local time zone. The base formula returns UTC. To convert to a fixed offset, add or subtract hours as fractions of a day. For UTC+2, use =A2/86400+DATE(1970,1,1)+2/24. For UTC-5, use ...-5/24. Daylight saving is not handled automatically, so use the offset that applies to the date you are converting.
  7. Fill down. Drag the fill handle from the first formula cell to the bottom of your data, or double-click it. Check that the cell references adjust correctly for each row.
  8. Convert the formula to values if needed. If you want to remove the formula, copy the results, then use Paste Special > Values in the same place. This is useful before sharing the file or importing into another system.

Common Mistakes

  • Using the wrong divisor. Dividing a 13-digit millisecond timestamp by 86,400 produces a date thousands of years in the future. Check the digit count first.
  • Leaving the cell formatted as General or Number. The formula is correct but shows a serial number such as 45261.5. Format the cell as a date/time.
  • Timestamps stored as text. Excel may not calculate on text values, or may return a #VALUE! error. Convert the column to numbers first.
  • Forgetting the time zone offset. A UTC timestamp converted without an offset can be hours off from the local time you expect, which matters when matching logs or events.
  • Using DATE(1970,1,1) with a locale that reads dates differently. The DATE function takes year, month, day in that order, so DATE(1970,1,1) is safe across regions; do not type a date string like "1/1/1970" into the formula.
  • Assuming Excel handles dates before 1900. Excel's date system starts at 1 January 1900, so epoch values that convert to dates before that (very small or negative timestamps) will show as errors or hashes.

Tips

  • Keep the original timestamp column and put the converted date in a new column, so you can verify results and re-run the conversion if needed.
  • Use a custom format such as yyyy-mm-dd hh:mm:ss for sortable, unambiguous output; avoid formats that depend on regional day/month order.
  • If you work with several time zones, add a helper cell for the offset in hours and reference it, for example =A2/86400+DATE(1970,1,1)+$B$1/24.
  • For readability in reports, you can use TEXT(A2/86400+DATE(1970,1,1),"yyyy-mm-dd hh:mm:ss"), but note the result becomes text and will no longer sort or calculate as a date.
  • If your data includes fractional seconds, the same formula works; format the cell with a custom format that includes .000 to see them.

Troubleshooting

The result shows a number like 45261.5. The formula worked; the cell is just not formatted as a date. Select it, press Ctrl+1, and choose a date/time format.

The result is a #VALUE! error. The timestamp is likely text, or contains spaces or non-numeric characters. Clean the column with Text to Columns or a formula such as =VALUE(TRIM(A2)) before converting.

The date is far in the future or past. You are almost certainly using the wrong unit. Divide by 86,400,000 for milliseconds, or by 86,400 for seconds, and check again.

The time is off by a few hours. Add or subtract your time zone offset as a fraction of a day. Remember that daylight saving changes the offset for part of the year.

The cell shows ##### . The column is too narrow. Widen it, or the date format is too long for the cell.

The formula returns a date before 1900. Excel cannot display dates before 1 January 1900 in its default date system. For very old timestamps, convert to text with a formula or handle the value outside Excel.

Frequently Asked Questions

What is an epoch timestamp?

It is the number of seconds (or milliseconds) that have passed since midnight UTC on 1 January 1970, not counting leap seconds. It is a common format in logs, APIs and databases.

Why do I need to add DATE(1970,1,1)?

Excel counts days from 1 January 1900, not 1970. Dividing by 86,400 converts seconds to days, and adding the 1970 date shifts the count to the correct starting point.

How do I convert milliseconds instead of seconds?

Divide by 86,400,000 instead of 86,400, or divide by 1,000 first and then by 86,400. The rest of the formula stays the same.

Does the formula account for daylight saving time?

No. The base formula returns UTC. You add a fixed offset for your time zone, so you need to apply the offset that matches the date, including daylight saving where it applies.

Can I convert a whole column at once?

Yes. Enter the formula in the first row, then drag the fill handle down or double-click it to fill the column. Format the whole column as a date/time afterward.

Why does my converted date show as text?

If you used the TEXT function, the result is text by design. Use the arithmetic formula and number formatting instead if you need the value to remain a real date.