Skip to content

Instantly share code, notes, and snippets.

@hasyimibhar
Created November 6, 2020 06:47
Show Gist options
  • Save hasyimibhar/bc8e17ce4f922253ede90b1070f3c1a1 to your computer and use it in GitHub Desktop.
Save hasyimibhar/bc8e17ce4f922253ede90b1070f3c1a1 to your computer and use it in GitHub Desktop.
formatjs/intl-datetimeformat with en-MY missing am/pm
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));
01 Feb 2020, 06:10:10
{
"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