I`m trying to convert a timestamp to an ISO8601 datetime-string.
E.g.
timestamp_as_iso8601_date=$(date --iso-8601=ns -d @1606982602015489365)
The timestamp is fairly long, with nanoseconds precision, and when I use the full timestamp it returns the following error:
date: time ‘1606982602015489365’ is out of range
The expected result should be: 2020-12-03T09:03:22,015489300+01:00
When I cut the timestamp to this: 1606982612
the error is gone but I loose information!
Is there any way to convert the timestamp without losing the milliseconds information?
Advertisement
Answer
Insert a comma:
date --iso-8601=ns -d @1606982602.015489365