[jq] Convert between ISO 8601 and Unix timestamps

Created on November 30, 2026

Use fromdateiso8601 and todateiso8601 to convert between UTC date strings and Unix timestamps in seconds.

Convert a date string to a Unix timestamp

Pass a value formatted as YYYY-MM-DDTHH:MM:SSZ to fromdateiso8601. The trailing Z denotes UTC.

printf '%s\n' '"2024-01-01T00:00:00Z"' | jq 'fromdateiso8601'
1704067200

Convert a Unix timestamp to a date string

Pass the timestamp in seconds to todateiso8601. Divide a timestamp in milliseconds by 1,000 first.

printf '%s\n' '1704067200' | jq 'todateiso8601'
"2024-01-01T00:00:00Z"

Reference

jq