Created
November 6, 2020 06:47
-
-
Save hasyimibhar/bc8e17ce4f922253ede90b1070f3c1a1 to your computer and use it in GitHub Desktop.
formatjs/intl-datetimeformat with en-MY missing am/pm
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
require('@formatjs/intl-datetimeformat/polyfill-force'); | |
require('@formatjs/intl-datetimeformat/locale-data/en'); | |
require('@formatjs/intl-datetimeformat/locale-data/en-MY'); | |
require('@formatjs/intl-datetimeformat/add-all-tz'); | |
var date = new Date(Date.UTC(2020, 1, 1, 10, 10, 10, 0)); | |
var format = new Intl.DateTimeFormat('en-MY', { | |
year: 'numeric', | |
month: 'short', | |
day: '2-digit', | |
hour: '2-digit', | |
minute: '2-digit', | |
second: '2-digit', | |
calendar: 'gregory', | |
hour12: true, | |
hourCycle: 'h12', | |
localeMatcher: 'lookup', | |
formatMatcher: 'best fit', | |
timeZone: 'Asia/Kuala_Lumpur', | |
}); | |
console.log(format.format(date)); |
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
01 Feb 2020, 06:10:10 |
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
{ | |
"dependencies": { | |
"@formatjs/intl-datetimeformat": "^2.8.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment