There is a very strange behavior of Intl.DateTimeFormat in case of ‘es-AR’ local when I try to format date for example :
const date = Date.UTC(2012, 1, 2, 14, 5, 42);
let format: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
timeZone: 'UTC',
}
let result = Intl.DateTimeFormat('es-AR', format).format(date);
I get the date 2/2/2012, 02:05:42
But when I use this formatOptions:
let format: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: '2-digit',
timeZone: 'UTC',
}
I am getting
2/2/2012, 2:05:42 p. m.
Why does this act so strangely?
Why I don’t get the AM/PM in the first case?
What should I do to get the AM/PM (my code should show am/pm in case the current local is 12h but don’t show it in case we use 24h )
Thanks