Skip to content

UTC

Guide

How to Convert Unix Timestamps in Excel and Google Sheets

Exports from X, APIs and analytics tools are full of Unix times. One short formula turns them into dates you can sort, chart and read.

TimeTweets team · updated · 5 min read

Short answer

In Excel or Google Sheets, divide a Unix timestamp in seconds by 86,400 and add the date 1 January 1970: =A2/86400+DATE(1970,1,1), then format the cell as a date and time. For milliseconds, divide by 86,400,000. Google Sheets also has =EPOCHTODATE(A2) for seconds and =EPOCHTODATE(A2,2) for milliseconds. The result is in UTC.

Key takeaways

  • Spreadsheets count dates in days, so divide Unix seconds by 86,400 (or milliseconds by 86,400,000).
  • Add DATE(1970,1,1) to shift from the Unix epoch to the spreadsheet's own date system.
  • The converted value is UTC; add or subtract hours divided by 24 for a local time zone.
  • Don't put 19-digit X post IDs in a number cell: spreadsheets keep only about 15 significant digits.

Unix timestamps turn up in almost every data export: API responses, analytics downloads, server logs and CSV files of posts. They are perfect for computers and unreadable for people. Spreadsheets can convert them with one formula, as long as you know which unit you have and remember that the result is in UTC. This guide has the formulas for Excel and Google Sheets, plus the traps that catch people most often.

What is a Unix timestamp?

A Unix timestamp is the number of seconds, or sometimes milliseconds, since 00:00:00 UTC on 1 January 1970.

So 0 is the start of 1970, and every second adds one. Many systems, including JavaScript and X's own post IDs, work in milliseconds instead. Our explainer on Unix time and UTC covers the background.

How do you convert a Unix timestamp to a date in Excel?

Use =A2/86400+DATE(1970,1,1) for seconds or =A2/86400000+DATE(1970,1,1) for milliseconds, then format the cell as a date and time.

Excel stores dates as the number of days since its own starting point, with the time of day as a fraction. A day has 86,400 seconds, so dividing a Unix time in seconds by 86,400 turns it into days since 1970. Adding DATE(1970,1,1) moves it onto Excel's calendar.

  1. Put the timestamps in column A, starting at A2.
  2. In B2, enter =A2/86400+DATE(1970,1,1).
  3. Fill the formula down the column.
  4. Format column B with a custom format such as yyyy-mm-dd hh:mm:ss.

The same formula works in Google Sheets, LibreOffice Calc and Numbers.

Is there a shortcut in Google Sheets?

Yes: =EPOCHTODATE(A2) converts seconds, and =EPOCHTODATE(A2,2) converts milliseconds, returning the date and time in UTC.

Google's help page lists three units: 1 for seconds (the default), 2 for milliseconds and 3 for microseconds. The function returns UTC regardless of the spreadsheet's own time zone setting, which is the safe behavior for data work. Format the result cell as a date and time if it shows as a number.

How do you convert a date back to a Unix timestamp?

Subtract DATE(1970,1,1) from the date and multiply by 86,400 for seconds, or 86,400,000 for milliseconds.

Goal Formula (date in A2)
Unix seconds =(A2-DATE(1970,1,1))*86400
Unix milliseconds =(A2-DATE(1970,1,1))*86400000
Whole seconds only =ROUND((A2-DATE(1970,1,1))*86400,0)

Make sure the date you start with is in UTC. If it is a local time, convert it to UTC first, or the timestamp will be off by your time zone offset.

How do you show the result in your own time zone?

Add or subtract the offset as a fraction of a day, for example +5/24 for UTC+5 or -8/24 for UTC-8.

For New York in winter (UTC-5), the formula becomes =A2/86400+DATE(1970,1,1)-5/24. The catch is daylight saving time: the offset changes during the year, and a fixed number can't follow it. For reports, it's often clearer to keep a UTC column and label it "UTC" in the header. If you need local times across a daylight saving change, convert them in a tool that knows the zone's rules, such as the event time converter.

How do you calculate the time between two timestamps?

Subtract one from the other: Unix values give the gap in seconds or milliseconds, and converted dates give it in days.

You have Formula Result
Two Unix times in seconds (A2, B2) =B2-A2 Seconds
Same, shown in minutes =(B2-A2)/60 Minutes
Two converted dates (A2, B2) =(B2-A2)*24 Hours
Two converted dates, as a duration =B2-A2, formatted as [h]:mm:ss Hours, minutes, seconds

The [h] format in square brackets lets the hour count go past 24, which a normal time format would wrap back to zero. This is handy for measuring how long replies took to arrive or the gap between posts in a thread.

Why do X post IDs break in spreadsheets?

Excel and Google Sheets keep only about 15 significant digits in a number, and X post IDs have 19 digits, so the last few digits are rounded away.

Microsoft documents a 15-digit precision limit for numbers in Excel. Paste 1795432109876543210 into a number cell and you get a different ID. That ID may not exist, and its decoded time can be slightly off. Store IDs as text by formatting the column as Plain text before pasting. To get posting times from many IDs, paste the links into the batch decoder instead. It decodes the full IDs in your browser and exports a CSV with both the ID and the UTC time, ready to open in a spreadsheet.

Questions people ask

How do I tell if a timestamp is in seconds or milliseconds?

Count the digits. Present-day Unix times in seconds have 10 digits, such as 1795000000, and in milliseconds they have 13 digits. If a conversion lands in 1970 or tens of thousands of years in the future, you used the wrong unit.

Why does my converted date show as a number like 46000?

The formula worked, but the cell is formatted as a number. Spreadsheets store dates as day counts. Change the cell format to a date and time format, or a custom one such as yyyy-mm-dd hh:mm:ss.

Does the formula handle daylight saving time?

No. Adding a fixed number of hours gives the right local time only for part of the year in zones that observe daylight saving. For exact local times across the year, keep the column in UTC or convert in a tool that knows the time zone rules.

Can I decode X post IDs in a spreadsheet?

Not reliably with ordinary formulas, because the 19-digit IDs lose their last digits when stored as numbers. Use the batch decoder, which handles the full IDs and exports a CSV with the times already worked out.

Sources

Pass it on X LinkedIn Reddit