Convert a timestamp
Problem / Use caseβ
You have a Unix timestamp (or timestamp string) and want to display it in a human-readable format for logs, alerts, or dashboards.
There are several ways that this conversion can be performed. You can choose the one that best fits your use case.
formatTimestampβ
formatTimestamp gives the user the flexibility to specify the output format. The first parameter is the timestamp and the second is the format. You ca use iso8601 without having to manually specify that format.
// date only
>>> formatTimestamp(1745905982439, '%Y-%m-%d')
'2025-04-29'
// time only
>>> formatTimestamp(1745905982439, '%H:%M:%S')
'05:53:02'
// date and time
>>> formatTimestamp(1745905982439, '%F %H:%M:%S')
'2025-04-29 05:53:02'
// iso8601 format (same as toIso8601DateTime)
>>> formatTimestamp(1745905982439, 'iso8601')
'2025-04-29T05:53:02.439Z'
Old deprecated method - toIso8601DateTimeβ
This shouldnβt be used, but you might see toIso8601DateTime in older queries. This function will accepts a timestamp as an argument and returns the corresponding ISO 8601 formatted time string.
>>> toIso8601DateTime(1745905982439)
'2025-04-29T05:53:02.439Z'
Since itβs deprecated use formatTimestamp(<timestamp>, 'iso8601') instead.
TL;DRβ
Use formatTimestamp with a parsed or converted timestamp for clean, flexible datetime formatting. Avoid toIso8601DateTime().