正在加载视频...

视频加载失败

The `Intl` object in JS is so valuable, yet so underutilized Learn how to generate friendly relative time strings from a given date - like "in 10 minutes" or "last week" or "tomorrow" - with 0 dependencies in my latest blog post:

267,870 次观看 • 3 年前 •via X (Twitter)

10 条评论

Steve (Builder.io) 的头像
Steve (Builder.io)3 年前

More of what you can do with `Intl.RelativeTimeFormat`, and some other super handy things you can do with `Intl`, in the full article:

Awa!s 的头像
Awa!s3 年前

Which software do you use for recording videos?

someone 的头像
someone3 年前

@theankurkedia check that out bro

n_oway 的头像
n_oway3 年前

nice one, the Spanish translation for the last one should be 'en 10 minutos' but seems to come back in English 🙃

Steve (Builder.io) 的头像
Steve (Builder.io)3 年前

doh, bad copy paste, will fix, thank you!

Koray 😷 的头像
Koray 😷3 年前

works good with money too. new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' } ).format(money);

Noah Vandervelden 的头像
Noah Vandervelden3 年前

Didn’t know how useful this was until working with currency in a recent project! Completely changed how I did currency, time, and a lot of other things Intl had to offer

RodAvi 的头像
RodAvi3 年前

Awesome tip Steve, thanks a lot. !!!

const name = 'David'; 的头像
const name = 'David';3 年前

This is great. Thanks for this. I have a collection of utility functions I use that keep me from needing things like lodash. I'm currently using date-fns, but need to see if this might be near enough to remove that dependency as well.

AleqsBrujo 的头像
AleqsBrujo3 年前

I like your tips! Ty for the research and most important for sharing it<3

相关视频