1. 4
    Getting Relative Time Dates That Are Locale Sensitive With Javascript Intl API
    3m 9s

Getting Relative Time Dates That Are Locale Sensitive With Javascript Intl API

Share this video with your friends

Send Tweet

Sometimes, you want to display the dates in a relative form, such as: 2 weeks ago. You can do this by doing some math and string concatenation with the dates, but Intl helps you with this.

When would you use something like this?

Imagine a list of articles, each article has a publication date, but you don't want to show just that. You want to show how much relative time is between the publication date and today (the day the user is reading the list).