How to Convert a Timestamp to Milliseconds in Google Sheets

Published on

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 KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV 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

Free Student Grade Tracker Template in Google Sheets

If you are looking for a simple way to track student grades, you are...

Free Monthly Expense Tracker Template in Google Sheets (Dashboard Included)

Watch the quick walkthrough below to see how to use this Free Monthly Expense...

The Complete Guide to XLOOKUP in Google Sheets (15+ Practical Examples)

The XLOOKUP function largely replaces traditional lookup functions such as LOOKUP, VLOOKUP, and HLOOKUP...

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.