Skip to content

Instantly share code, notes, and snippets.

@chinchang
Created June 11, 2020 17:47
Show Gist options
  • Save chinchang/f33158b47c38135c19ebec867491a82e to your computer and use it in GitHub Desktop.
Save chinchang/f33158b47c38135c19ebec867491a82e to your computer and use it in GitHub Desktop.
relative time format
new Intl.RelativeTimeFormat('en', {
style: 'narrow'
}).format(-10, 'day')
// "10 days ago"
new Intl.RelativeTimeFormat('en', {
style: 'narrow'
}).format(10, 'day')
// "in 10 days"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment