Video yükleniyor...
Video Yüklenemedi
It's 2026. You don't need a library for formatting dates in JavaScript. Just use Intl 👇
148,678 görüntüleme • 10 ay önce •via X (Twitter)
36 Yorum

@YBenlemlih For better performance, use

@YBenlemlih It’s 2026, why not use Temporal🤨

@YBenlemlih how do you make these code animations?

👇

@YBenlemlih thank you!

@YBenlemlih Unfortunately JS does not handle the timezone issue well. If you don’t have this issue, good for you. I will wait for Temporal. Till then, still in 2026, I use date-fns

@YBenlemlih That’s great news 👍

@YBenlemlih I guess 2026 has to be formatted using Intl

@YBenlemlih There's 'toLocaleString()' which I believe you'll easily remember. Works the same as Intl

@YBenlemlih but library still makes the job much easier. I use dayjs, and it works seamlessly i'l save this for the future, thanks!!

@YBenlemlih What's the different between this and dayjs?

@YBenlemlih javascript has so many hidden treasures. it's good to have a treasure hunter like you amongst us.

@YBenlemlih Technically we never needed any libraries, even back in the jquery days. But JavaScript sucks on every level, and everyone desperately attempts to use band aids & duct tape

@YBenlemlih Intlesting 🤔
@YBenlemlih "You don't need a library".. except, you kinda do. Because, yes, you got the correct format.. but you got the wrong timezone.. 14:35:20Z is gonna be like 8:35AM for most of America right?

@YBenlemlih i knew intl was the move years ago

@YBenlemlih New update

@YBenlemlih For more control and parsing:

@YBenlemlih same for time, number etc

@YBenlemlih date-fns

@YBenlemlih My AI agent already used this

@YBenlemlih Absolutely!

@YBenlemlih There are tons of npm packages that do the same thing and export their custom hooks and functions, but under the hood, they are using this exact utility

@YBenlemlih

@YBenlemlih Happened to me today : ki() is compiled name for Angular's formatDate() function. Silly us trying to format a string instead of a Date, but 1) it doesn't bother Angular as it still tries to cast to a Date then format 2) it was doing fine with "2025-12-23" soooo

@YBenlemlih JS has some hidden gems.

@YBenlemlih Cool

@YBenlemlih In more complex apps, formatting is only ~10% and using Luxon (and other libs) gives better api and more functionality: timezones/offsets, add/remove days/minutes, startOf/endOf, from/to ISO, DateTime<isValid?>, etc

@YBenlemlih This is so cool I learn it this year and never installed a library again

@YBenlemlih I am happy that JS has this built-in but the DX of date-fns is way better

@YBenlemlih I used to use moment.js Intl is much better and it's native

@YBenlemlih I guess this is the end of the road for me with date-fns.

@YBenlemlih cool animation!

@YBenlemlih Crazy library

@YBenlemlih Bro prepared the post for next year's algo

@YBenlemlih The new animation posts are really nice, and they are going viral 🚀
