How to convert Unix timestamps in Excel and Google Sheets
Updated
Spreadsheets don’t store dates as Unix timestamps. Excel and Google Sheets use a serial date: the number of days since a starting date (30 December 1899 in practice), with the time of day as a fraction. Noon on 1 January 2025 is stored as 45658.5. Converting between the two systems takes one formula.
Timestamp to date
Divide seconds by 86,400 (the number of seconds in a day) to get days, then add the serial number of 1 January 1970. With the timestamp in cell A2:
=A2/86400 + DATE(1970,1,1)=A2/86400000 + DATE(1970,1,1)The result is a number like 45658. Format the cell as a date-time to see it as a date: in Excel use Format Cells → Custom with yyyy-mm-dd hh:mm:ss; in Google Sheets use Format → Number → Date time.
Google Sheets shortcut
Google Sheets also has a dedicated function:
=EPOCHTODATE(A2) // seconds
=EPOCHTODATE(A2, 2) // milliseconds (3 = microseconds)Date to timestamp
Reverse the calculation — subtract the epoch and multiply by seconds per day:
=(A2 - DATE(1970,1,1)) * 86400 // seconds
=(A2 - DATE(1970,1,1)) * 86400000 // millisecondsFormat the result cell as a plain Number with no decimal places, otherwise the spreadsheet may display it as a date or in scientific notation.
Adjusting for time zones
These formulas produce UTC. Spreadsheets have no concept of time zones for cell values, so if you want local time, add or subtract the offset as a fraction of a day:
=A2/86400 + DATE(1970,1,1) + 1/24=A2/86400 + DATE(1970,1,1) - 5/24A fixed offset doesn’t follow daylight saving changes. If your data spans both summer and winter, either keep everything in UTC (usually the better choice for analysis) or convert the timestamps to local time before importing them.
Common problems
- The result shows as a big number, not a date. The formula worked — apply a date format to the cell.
- Every date is in 1970. Your timestamps are probably in milliseconds; divide by 86,400,000 instead of 86,400.
- The timestamp is stored as text. Values imported from CSV or JSON are sometimes text. Wrap the cell in
VALUE():=VALUE(A2)/86400 + DATE(1970,1,1). - Precision on long timestamps. Spreadsheets hold 15 significant digits, so nanosecond timestamps (19 digits) lose precision. Trim them to milliseconds before importing.
- Dates are four years off in an old Mac workbook. Excel for Mac once defaulted to a 1904 date system. Using
DATE(1970,1,1)rather than a hard-coded25569keeps the formula correct in either system.