I realise that JSON has no real date format and that using ISO 8601 is a good bet given that's what JavaScript uses. What about a duration? JavaScript has no built in format.
- I came across ISO 8601 Durations e.g.
P3Y6M4DT12H30M5S
which I haven't seen used much in the wild. It also looks very verbose and difficult to read. As far as I can see it also does not support milliseconds if you needed that. - I'm using C# whose
TimeSpan
type outputs1.02:03:04.0050000
for 1 day, 2 hours, 3 minutes, 4 seconds and 5 milliseconds. - I could use the number of seconds or milliseconds as an integer. This is completely machine readable only and it's not obvious if you are using seconds or milliseconds without labelling the value as such.
I've hardly ever seen the first format in the wild. The second seems more intuitive to me but I'm worried that it's not as well known outside of .NET. The third format is probably the most cross platform friendly but totally not human readable.