Working with a date and time in JS was awful in the past. I dont know about you, but I used MomentJS or date-nfs library.
Now it is possible to start using the Internationalization API for formating a date and time. Support is good in all browsers.
Let see an example:
If you want to use the browser’s locale, you must pass an empty Array in the constructor. The second argument is options. For more details see the documentation.
There is a Intl.RelativeTimeFormat() class for relative manipulation with a date and time. The Intl.RelativeTimeFormat is similar to the Intl.DateTimeFormat.
Let see an example:
Bonus :)
No comments:
Post a Comment