Hacker News new | ask | show | jobs
by joenot443 1346 days ago
If I were helping someone start a web project _right now_ I'd probably tell them to just use Moment.js and forget about it. Any live web product I've ever worked on has always had more than enough to work on to keep updating the date-time library at the bottom of the to-do list almost indefinitely.
3 comments

Moment’s website suggests using other more modern alternatives so probably not a good idea to use it on a new project.
I was tangentially involved in the back-end data part of a web project in the last few weeks.

Right from the beginning, I told anyone who would listen that the underlying data was in UTC. So far, so good.

They get to T-24h for the client's Big Demo Day...

...and someone in London, UK notices the front end UI times are all an hour out (that would be because the UK is still on summer time, UTC+1). I happened to be in Germany and after finally being given a login for the UI found that, wonder of wonders, the timings were two hours out!

<groan>

So we had to bodge the API to fiddle the times forward to UTC+1 for the purposes of the damned demo.

Someone is presumably going to find this in the repo waaaay in the future and ask themselves "wtf were they thinking?". I wish I knew the answer.

I wouldn't recommend anyone use moment.js if they're starting a new project. It's an unnecessarily large library, and the fact that moment objects are mutable almost always causes more issues than it solves. The only reason to use it is if you're working on software that is already using it. Otherwise use a more modern, immutable datetime library like day.js, date-fns, or luxon.