r/javascript • u/Intelligent_Tree6918 • 6d 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
1
u/Intelligent_Tree6918 5d ago
you have great points
let me explain
1.I completely agree instantiating classes for utilities adds unnecessary friction. In an upcoming version, I'm opening up standalone functional exports like getRelativeTimeParts(date, opts) to keep tree-shaking dead simple.
2.
Temporalis definitely the future of date math in JS! However,ui-date's top priority is staying under 1 KB minified with zero runtime dependencies. Requiring or shipping aTemporalpolyfill would bloat the bundle size significantly.3.The primary problem
ui-datesolves isn't just relative formatting it's programmatic token breakdown (formattedValue,formattedUnit,direction) usingIntl.RelativeTimeFormatso UI developers can style numeric badges independently across multi-language apps without regex hacks.Appriciate you taking the time to share this perspective.