Discussion

Ask HN: Why is a Unix timestamp not a “valid date string” in the spec?

While implementing an HTML <time> element recently I found it strange that it did not accept a Unix timestamp as valid input for it's contents or it's datetime attribute.

Taking a look at the spec [1], the W3C states that the input must be a "valid date string with optional time". This, in turn, links through to the microsyntax spec [2], which gives a number of acceptable input patterns - none of which are a Unix timestamp.

I find this to be a curious design decision as the purpose for the time element itself, as stated by the W3C, is "...a way to encode modern dates and times in a machine-readable way..." - and what would be more machine-readable than a Unix timestamp?

Is it simply because a Unix timestamp is - on it's face - a number and not a string? Just wondering if anyone here had any additional insight.

[1] https://www.w3.org/TR/2011/WD-html5-author-20110809/the-time-element.html

[2] https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string-with-optional-time

3 points kaishiro 5 years ago 3 comments

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton