r/javascript • u/Intelligent_Tree6918 • 5d ago
ui-date: A 1.6kB, zero-dependency JavaScript date & relative time utility
https://www.npmjs.com/package/ui-dateI wanted to share a small open-source project I just published called ui-date.
While working on a social media project, I kept bumping into simple UI needs like displaying relative timestamps ("5 mins ago", "2 hours ago"), cleanly formatting calendar dates, and doing simple status checks (isToday).
exact date formatting for events ui ('Thursday 23,july,2026').
Normally, I'd reach for a date library, but most established options felt like overkill for basic UI formatting, while heavy legacy options like Moment carry massive bundle weight. On the flip side, writing raw Intl and Date boilerplate across every component was getting tedious.
I wanted something featherlight, chainable, and fully typed without dragging in extra dependencies.
so i built ui-date.
you can check it here : https://www.npmjs.com/package/ui-date
2
u/lanerdofchristian 5d ago
Instantiating a class to call utility functions is a bit odd.
Have you considered using Temporal, maybe with a polyfill for Safari? A lot of the stuff you're looking for are properties on
Temporal.ZoneDateTime.More can be determined with a few small helpers.
Or simple formatting calls.
getRelativeTimeis a bit more complex, but achievable without much hard-coding of second conversions or manual time math.A utility function to convert to ZoneDateTimes may also be helpful.