-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Considering most web pages now are consumed all around the world, it would make sense to have an HTML-only solution to display some globally specific point in time (relativity jokes aside) to the user in user's preferred format and time zone.
As a server author, I mostly store my timestamps either in UTC, or with timezone info attached. Neither of them would be helpful to a user, who is in a different timezone.
There are two common approaches as to how to solve this simple task right now: server-side rendering, and JavaScript-based rendering.
The biggest disadvantage of the first one is a privacy problem, as it forces the user to expose his timezone to the server. Also, rendering different time for different users negatively affects page caching.
The problem with JavaScript-based approach is, of course, JavaScript. It can be disabled, or accidental errors, which happen elsewhere, might mislead user (e.g. if they end up seeing mixed adjusted and non-adjusted time stamps). Plus, it has to be implemented/properly used almost in every product.
That kind of tag would be useful on almost every website, Facebook, Youtube, and this very page included.
IMHO, <time> tag can be reused for that purpose, if left empty, datetime is set, and some attribute set to a value, describing the desired format of the display. For example, <time datetime='2017-03-02T07:02:20Z' format='date-only'> to show '02-03-2017' to people with French locale. And 'short-time' could show 08:02 for UTC+1.