How to Use EPOCHTODATE Function in Google Sheets

This guide will explain how to use EPOCHTODATEfunction in Google Sheets.

When we need to convert Unix epoch timestamps to UTC, we can easily do this using the EPOCHTODATE function in Google Sheets.

The rules for using the EPOCHTODATE function in Google Sheets are the following:

  • The EPOCHTODATE function is used to convert a Unix epoch timestamp to a DateTime in Universal Time Coordinated (UTC).
  • The default unit of time is seconds.
  • The fractional amounts of milliseconds are shortened.
  • The function will return the UTC and not the local time zone of our spreadsheet. 
  • The function does not accept negative timestamps.

Google Sheets has several built-in functions that deal with date-related situations or conversions. Some examples of date-related functions in Google Sheets are the DATEDIF function, the DAYS function, and the DATEVALUE function.

The EPOCHTODATE function specifically converts Unix epoch timestamps to UTC. The Unix epoch refers to the number of seconds that have passed since January 1, 1970, not counting leap seconds. 

In this guide, we will provide a step-by-step tutorial on how to use the EPOCHTODATE function in Google Sheets. Additionally, we will explore the syntax and a real example of using the function.

Great! Let’s dive right in.

The Anatomy of the EPOCHTODATE Function

The syntax or the way we write the EPOCHTODATE function is as follows:

=EPOCHTODATE(timestamp,[unit])
  • = the equal sign is how we begin any function in Google Sheets.
  • EPOCHTODATE() refers to our EPOCHTODATE function. This function is used to convert a Unix epoch timestamp in seconds, milliseconds, or microseconds to a DateTime in Universal Time Coordinated (UTC).
  • timestamp is a required argument. This refers to the Unix epoch timestamp in seconds, milliseconds, or microseconds we want to convert.
  • unit is an optional argument. This is the unit of time in which the timestamp is expressed. By default, the function expressed the timestamp in seconds. 

EPOCHTODATE Function Unit Options

The EPOCHTODATE function has an optional unit argument which allows us to decide what unit of time we want to express the timestamp in. 

The table below shows the different options we can choose.

Unit OptionDescription
1This is the default option. The function will express the timestamp in seconds.
2The function will express the timestamp in milliseconds.
3The function will express the timestamp in microseconds.

A Real Example of Using EPOCHTODATE Function in Google Sheets

Let’s say we have a data set containing several Unix epoch timestamps. Our initial data set would look like this:

Initial dataset

In the spreadsheet above, we can see the Unix epoch timestamps in different units of time, such as seconds, milliseconds, and microseconds. Our goal is to convert these timestamps into a DateTime in Universal Time Coordinated. 

We must remember that the Unix epoch time is the seconds elapsed since the 1st of January 1970. Thus, we cannot convert a date that happens before the 1st of January 1970. 

We can use the formula below to convert Unix epoch timestamps:

=EPOCHTODATE(A2,1)

EPOCHTODATE formula for seconds

The first part of the formula is simply referring to the cell containing the Unix epoch timestamp we want to convert. Then, we need to input the appropriate unit argument. 

In the first row of the data set, the Unix epoch timestamp is in seconds. Hence, we will input 1, which refers to the time unit seconds as our unit argument. 

The next row of the data set is a Unix epoch timestamp in milliseconds. Thus, the formula we would be using is=EPOCHTODATE(A3,2)

EPOCHTODATE formula for milliseconds

This time, the unit argument is 2, which is the unit option for the time unit milliseconds. 

Lastly, the last row is a Unix epoch timestamp in microseconds. Our formula would be =EPOCHTODATE(A4,3)

EPOCHTODATE formula for microseconds

The unit argument is 3, which is the unit option for the time unit microseconds. 

Our final data set would look like this:

Final dataset

You can make your own copy of the spreadsheet above using the link below. 

Amazing! Now we can dive into the steps of using the EPOCHTODATE function in Google Sheets.

How to Use EPOCHTODATE Function in Google Sheets

1. First, we will create a new column to input the converted timestamps. 

EPOCHTODATE Function in Google Sheets

2. In the first row of the new column, we will type in an equal sign and the EPOCHTODATE function. This will make our formula “=EPOCHTODATE(”.

EPOCHTODATE Function in Google Sheets

3. We will select the cell containing the timestamp we want to convert. In this case, our formula will be “=EPOCHTODATE(A2”.

EPOCHTODATE Function in Google Sheets

4. Since the timestamp is in seconds, we will input the unit option 1. Our final formula will be “=EPOCHTODATE(A2,1)”.

EPOCHTODATE Function in Google Sheets

5. We will press the Enter key to return the result.

EPOCHTODATE Function in Google Sheets

6. Next, we will convert the Unix epoch timestamp that is in milliseconds. To do this, we will again type in the EPOCHTODATE function and select the cell that has the timestamp. Our formula will be “=EPOCHTODATE(A3”.

EPOCHTODATE Function in Google Sheets

7. This time we will use the unit option for milliseconds which is 2. Thus, our formula will be “=EPOCHTODATE(A3,2)”.

EPOCHTODATE Function in Google Sheets

8. We will press the Enter key to return the result.

EPOCHTODATE Function in Google Sheets

9. Then, we can move on to the last timestamp, which is in microseconds. Similarly, we will type in the function and select the cell containing the timestamp. Our formula will be “=EPOCHTODATE(A4”.

EPOCHTODATE Function in Google Sheets

10. We will utilize unit option 3, which is for microseconds. Our final formula would be “=EPOCHTODATE(A4,3)”.

EPOCHTODATE Function in Google Sheets

11. Lastly, we will press the Enter key to return the results.

EPOCHTODATE Function in Google Sheets

And tada! We have successfully used the EPOCHTODATE function in Google Sheets.

You can apply this guide whenever you need to convert Unix epoch timestamps in seconds, milliseconds, and microseconds into Universal Time Coordinated. You can now use the EPOCHTODATE function and the various other Google Sheets formulas available to create great worksheets that work for you.

FAQs:

1. Will the converted timestamp be in my local time zone? 

No. The EPOCHTODATE function will always convert to the Universal Time Coordinated (UTC). If you want to convert it to your local timezone, you can add your GMT offset from the returned date using the + symbol.

Let’s say your timezone GMT is +8 hours. You can simply add this to your formula. Thus, your final formula would be =EPOCHTODATE(B2,1)+time(8,00,0).

2. What is the use of the Unix epoch timestamp?

The Unix epoch time is a timestamp represented by the number of seconds passed since January 1, 1970. This specific timestamp can be used as an integer, making it easier to compute and use across different systems. 

That’s pretty much it! Make sure to subscribe to our newsletter to be the first to know about the latest guides and tutorials from us.

Get emails from us about Google Sheets.

Our goal this year is to create lots of rich, bite-sized tutorials for Google Sheets users like you. If you liked this one, you'll love what we are working on! Readers receive early access to new content.

 

0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like