Hacker News new | ask | show | jobs
by jake-low 2441 days ago
Definitely agree about the loss of precision. It's also a problem for machine readability and SEO. The solution I like is using the HMTL5 <time> element for semantic markup of timestamps. If you do something like this:

    <time datetime="2019-10-11T13:53:36.861" title="Fri Oct 11 2019 13:53:36 GMT-0700">2 minutes ago</time>
Then you get what in my opinion is the best of both worlds: machine readable timestamp in the datetime field, human-friendly detailed timestamp as a tooltip (the title field shows when you hover over the element), and relative time as the default display. Bonus points if your React component or ERB template or whatever switches from relative time format to absolute for the inner text when the timestamp is older than a day or so.
1 comments

"when you hover over the element"

On the website I'm looking at Google Analytics for right now, fewer than 35% of the visitors are from devices where "hover" means anything...

Well, it would require JS, but you could turn it into a button to show/hide an HTML tooltip or additional displays of the time. That iOS supports a mouse (in accessibility settings) or an Xbox controller but doesn’t properly support an “abbr” tag... it was acceptable in 2007 when we were happy to see the phone load nytimes.com with all its columns. It’s feeling very out of date in 2019, when 12 years later we’re adding downloads and “desktop safari” but we never finished the “desktop-equivalency” parts of the HTML5 spec. It would be amazing if Apple ported some of their iOS native components to web components or to enhance HTML5 elements. The farthest we’ve gotten so far are keyboard search button hints, if I recall correctly. Which is really quite disappointing, that an app made for jQuery UI would work as well as an app from today if you flatten and modernize the design, and add a bit of offline caching...