Last active
November 13, 2019 12:07
-
-
Save SarathSantoshDamaraju/b4ccb12c09d64b4344153d4580351b39 to your computer and use it in GitHub Desktop.
Intl() gist #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict;' | |
| let timeDiff = Math.ceil((new Date('2019-11-12T11:38:02.787Z') - new Date())/86400000); | |
| /* | |
| 86400000 is to convert the time to days. | |
| 1000 to convert it into seconds | |
| 1000*60 to convert it into minutes | |
| 1000*60*60 to convert it into Hours | |
| */ | |
| const localTimeString = new Intl.RelativeTimeFormat('en', { numeric: 'auto'}); | |
| localTimeString.format(timeDiff, 'days'); // Prints yesterday |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment