HomeGoogle DocsSpreadsheetHow to Convert a Timestamp to Milliseconds in Google Sheets

How to Convert a Timestamp to Milliseconds in Google Sheets

You can convert a timestamp to Unix time in milliseconds using simple formulas in Google Sheets—no scripts needed. This is useful for working with APIs, logs, or systems that require timestamps in Unix format.

Before diving into the formula, let’s quickly review what Unix time is.

What Is Unix Epoch Time?

Unix-based systems measure time from a fixed starting point: January 1st, 1970, 00:00:00 UTC, also called the Unix Epoch.

  • Unix time in seconds is the number of seconds elapsed since this point.
  • Unix time in milliseconds multiplies that count by 1,000.

In this tutorial, you’ll learn how to convert a timestamp in Google Sheets to Unix time in milliseconds, with optional formulas for seconds and microseconds.

How to Set and Use Time Zones in Google Sheets

Before converting timestamps, make sure your Google Sheet is using the correct time zone.

How to Set Your Sheet’s Time Zone:

  1. Go to File > Settings
  2. Under the General tab, choose the correct Time zone
  3. Click Save settings
Selecting the correct time zone in Google Sheets spreadsheet settings

Now, using =NOW() will return your local time accurately.

How to Convert Local Time to UTC in Google Sheets

Google Sheets stores timestamps in local time. To get the correct Unix time, you need to convert local time to UTC (GMT).

UTC Conversion Formula

If your time zone is UTC+5:30, subtract 5.5 hours:

=A1 - 5.5/24

If your time zone is UTC−7:00, add 7 hours:

=A1 + 7/24

Rule of thumb:

  • If your local time is UTC+, subtract the offset
  • If UTC−, add the offset

Step 3: Convert Timestamp to Unix Time in Milliseconds

Once your timestamp is in UTC, use this formula to convert it to milliseconds since Unix Epoch:

Formula:

=(A1 - [UTC Offset] - DATE(1970,1,1)) * 86400000

Example:

If A1 = 4/8/2017 11:30:00 and your time zone is UTC+5:30:

=(A1 - 5.5/24 - DATE(1970,1,1)) * 86400000

Result: 1501826400000 (Unix time in milliseconds)

Example of a Google Sheets formula converting a timestamp to milliseconds

Convert Current Timestamp to Milliseconds

Use the NOW() function instead of a cell reference:

=(NOW() - 5.5/24 - DATE(1970,1,1)) * 86400000

This gives you the current time in milliseconds, adjusted for your time zone.

Additional Variations

UnitFormula
Seconds=(NOW() - 5.5/24 - DATE(1970,1,1)) * 86400
Microseconds=(NOW() - 5.5/24 - DATE(1970,1,1)) * 86400000000

Change the time zone offset (5.5/24) based on your own.

Resources

Prashanth K V
Prashanth K V
Your Trusted Google Sheets and Excel Expert Prashanth K V is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Top Discussions

More like this

Home Maintenance Tracker Template for Google Sheets (Free & Automated)

Keeping up with home maintenance can be challenging, especially when you need to track...

Sheetogram: Free Nonogram Game for Google Sheets (10×10 Puzzle Template)

Recently, I built Sheetogram, a Nonogram game for Google Sheets, as a passion project....

How to Generate Unique 10×10 Nonogram Puzzles in Google Sheets

Creating nonogram puzzles in Google Sheets is surprisingly easy. All you need is a...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.