What is a good format for Duration in JSON?
Basically, duration is a number of milliseconds or ticks (if you need higher precision).
1 tick is 100 nanoseconds. There are 10,000 ticks in a millisecond.
ISO 8601: the existing standard
The best way is to use common standard that you mentioned ISO 8601. It's human and machine readable.
What is easier to read and change for you?
- 1036800000 ms
You can use ISO 8601 duration like
P1Y2M10DT2H30M in different ways:
- Pass in JSON format as a
- Handle by NodaTime in C#
- Store in DB
Keep in mind that ISO 8601 also resolves the issue when switching from or to Daylight saving time.
PT36His not the same as
There are different schemas for structured data on the Internet on schema.org. Number of them are using Duration which should be represented by
ISO 8601 duration format.