Category: FUNCTION | Updated: 2026-11-22
EPOCHTODATE Function
EPOCHTODATE Function
The EPOCHTODATE function in Google Sheets converts a UNIX epoch timestamp (seconds elapsed since January 1, 1970, 00:00:00 UTC), commonly found in system logs and API data, into a standard date-time format usable in Sheets.
Syntax
=EPOCHTODATE(timestamp, [unit])
- timestamp: The UNIX epoch timestamp (a positive integer) to convert.
- unit (optional): A number from
1to3specifying the unit of the timestamp. Defaults to1(seconds) if omitted.1(or omitted): Seconds (10-digit number)2: Milliseconds (13-digit number)3: Microseconds (16-digit number)
Practical Examples with a Table
This example converts UNIX timestamps (in seconds and milliseconds) retrieved from a system into date-times, and then adjusts them to Japan Standard Time (JST: UTC+9 hours).
| A (Log Type) | B (Timestamp) | C (Unit Code) | D (Converted - UTC) | E (Japan Time - JST) | |
|---|---|---|---|---|---|
| 1 | Log Type | Timestamp | Unit | Converted (UTC) | Japan Time (JST) |
| 2 | Payment Log (sec) | 1795478400 | 1 | =EPOCHTODATE(B2, C2) |
=D2 + TIME(9, 0, 0) |
| 3 | Access Log (ms) | 1795478400000 | 2 | =EPOCHTODATE(B3, C3) |
=D3 + TIME(9, 0, 0) |
- Result in D2:
2026/11/24 0:00:00(Displays the date and time in Coordinated Universal Time) - Result in E2:
2026/11/24 9:00:00(Adding 9 hours converts it to Japan Standard Time) - Result in D3:
2026/11/24 0:00:00(A 13-digit millisecond timestamp is also converted accurately by specifying2as the unit)
Common Errors and Precautions
- Watch out for time zone differences (9-hour offset between UTC and JST):
- Regardless of your spreadsheet’s time zone setting,
EPOCHTODATEalways returns Coordinated Universal Time (UTC). If you need Japan Standard Time, be sure to add+ TIME(9, 0, 0)(or+ 9/24).
- Regardless of your spreadsheet’s time zone setting,
- When
#NUM!errors occur:- Occurs if you pass a negative timestamp (before January 1, 1970), specify a unit other than
1–3, or pass a value so large it exceeds Google Sheets’ maximum date limit.
- Occurs if you pass a negative timestamp (before January 1, 1970), specify a unit other than
- Mismatch between digit count and unit:
- Passing a 13-digit (millisecond) timestamp while omitting the unit (treating it as seconds) results in a date far in the future (such as the year 58000) and triggers a
#NUM!error, so always check the number of digits.
- Passing a 13-digit (millisecond) timestamp while omitting the unit (treating it as seconds) results in a date far in the future (such as the year 58000) and triggers a
Frequently Asked Questions
Q. How do I convert a 13-digit UNIX timestamp in milliseconds?
A. Specify '2 (milliseconds)' for the second argument 'unit'. Use '1' (or omit it) for 10-digit timestamps in seconds, and '3' for 16-digit timestamps in microseconds.
Q. How do I convert the date and time returned by EPOCHTODATE to Japan Standard Time (JST)?
A. Because EPOCHTODATE returns Coordinated Universal Time (UTC), add '+ TIME(9, 0, 0)' or '+ 9/24' to the result to advance it by 9 hours for JST.