Sample Header Ad - 728x90

ISO 8601 intervals in date arithmetic with date command

4 votes
1 answer
329 views
I can make some date arithmetic with date command like
$ date -u -d '3 days 2024-12-01T00:00:00Z' +%FT%H:%M:%SZ
2024-12-04T00:00:00Z
$
The date command can parse quite a lot of date formats, including ISO-8601 formats. Is there an easy way to make it to interpret also ISO-8601 intervals? Naive approach fails...
$ date -u -d 'PT3D 2024-12-01T00:00:00Z' +%FT%H:%M:%SZ
date: invalid date ‘PT3D 2024-12-01T00:00:00Z’
$
Asked by Roux (143 rep)
Dec 1, 2024, 08:00 PM
Last activity: Dec 2, 2024, 12:09 PM