hckrnws
A while back, I've decided to make time tags dynamic on my website. First of all they have the title tag to show the actual date in UTC. By dynamic I mean, when something is just published, I use relative time that updates in real time. 1 second ago, 2, 3... etc. Then the minutes, then the hours, then daily.
I always get frustrated when I see a 7 months ago, or X years ago, the math is always inconsistent when they round it. So when something is more than 3 days old, I display the actual date.
The way that this is handled on most websites is that you show "X time ago" but you can hover over the time to get the full timestamp. For example, that's how it's handled here on Hacker News and Reddit.
Which is great UX on a phone.
> I always get frustrated when I see a 7 months ago, or X years ago, the math is always inconsistent when they round it. So when something is more than 3 days old, I display the actual date.
What especially makes me angry is dev tools doing this.
No, Github, Circle CI or Google Console [1] and others. I need to see actual timestamps on commits, PRs, merges, logs etc. not the bullshit "7hrs ago" when I'm trying to find out what broke.
[1] At one point a few years back their log viewer would show this. Someone actually implemented it because showing this is more work than actual proper timestamps.
Take a look at GitHub’s <relative-time> element - works great as a progressive enhancement: https://github.com/github/relative-time-element
Wouldn't it make sense if the content of it could be auto-generated as well for the users' locale directly with no need for JS?
Either as a date in the example "4 days ago" or "in 2 days, 2 hours and 28 seconds" for future events. This requires some control for granularity to control for how precise you want it to be and what to omit.
"a few seconds ago", "3 seconds ago", "less than a minute ago".
Should support a shortform that can act as a countdown timer "00:00:56" or "00:56".
It's wild to me that it doesn't even generate a tooltip by default.
I agree it should do something, which might be configurable by the end user and implementation dependent. For example, a browser might have an option to display the time converted into your preferred time format and time zone. If the operating system environment has some way to specify that some text refers to date/time and can be used with other software in this way, then it would be possible to do that, too.
(My own Scorpion document format is intended to include this capability, as well as the ability to specify other things (e.g. units of measurement, international telephone numbers, how a word is pronounced, languages, etc) to be handled in similar ways, but it is not currently fully defined.)
Similar gripe of mine, why doesnt input `datetime-local` add the timezone on the client side...
> Post published 4 hours ago
Am I the only one who dislikes these relative times and prefers absolute date stamps?
Especially "1 year ago" (for something that was 23 months ago)
Relative times are nice for recent times (e.g. "5 minutes ago" is better than "2025-12-18 13:03"), but they should "decay" into absolute times for anything that isn't fairly recent - like a week or two, perhaps.
It varies by use case. I can think about e.g. an SRS flash card where you next review is in 2 years. I honestly don‘t care if 2 years here means 21 months or 28 months, and I especially don‘t care if the next review is on 21st of February 2028 at 13:52. All I want to know is that the next review is so far in the future it may not actually happen.
That's a fair point. I'm thinking of the use case of formatting a past date on something like a social media post/comment. (For example, a comment on HN - which uses a rather long cutoff for relative dates.)
I agree with you, I also prefer absolute date stamps, including because it might be printed out, etc. However, the <time> command would allow that to work, if it is implemented in a way that allows that to work.
Comment was deleted :(
It is particularly annoying in a screenshot or printed document. I rarely print onto paper, but occasionally, I will "print" an interesting blog post into a PDF.
I like it but I think the granularity needs to be fixed. For example, the cutoff points should be 21+ months -> 2 years instead of 13+ months -> 1 year.
So basically you want the cutoff to be > 1.66 of the next unit before you display in that unit. That means 40 hours, 2 days; 11 days, 2 weeks; 6 weeks, 2 months; 20 months, 2 years.
Tooltips are struggling on mobile.
It has done nothing for so long that it may now be impossible to make it do something useful.
bring back <blink> more like ittt
Then write a browser plugin that does these things to the <time> element.
Personally I always use the <time> element when providing date or time. Properly localized with Intl.DateTimeFormat and ISO string formatted in the datetime attribute. I do it mostly because it is free. For a developer writing <time> instead of <span> makes no difference. <time> is easier to target in tests, and maybe my users has a browser plugin that can quickly e.g. add a thing to their day planner app from a <time> element.
Crafted by Rajat
Source Code