Created
May 19, 2019 08:29
-
-
Save akmamun/d89475696b99d3e01cb826815ec4479b to your computer and use it in GitHub Desktop.
JS Date Time
This file contains 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
const options = { | |
year: 'numeric', | |
month: 'numeric', | |
day: 'numeric', | |
hour: 'numeric', | |
minute: 'numeric', | |
second: 'numeric' | |
} | |
new Intl.DateTimeFormat('en-US', options).format(date) //"7/22/2018, 7:22:13 AM" | |
new Intl.DateTimeFormat('it-IT', options2).format(date) //"22/7/2018, 07:22:13" | |
getFormatDateTime = (dateTime) => { | |
let now = new Date(dateTime); | |
let options = { | |
year: 'numeric', | |
month: 'short', | |
day: 'numeric', | |
hour: '2-digit', | |
minute: '2-digit' | |
}; | |
return now.toLocaleString('en-BD', options); //July 1st 2018, 10:20AM | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment