Reputation: 405
I have below JS code
let options = { hour12: false, timeZone: 'America/Chicago', timeStyle: 'short' };
let myDate = new Date('2021-06-07T05:46:00.000Z').toLocaleTimeString("en-US", options);
The expected output from above is 00:46 as I am using hour12 to false but instead it returns 24:46 which is an invalid time, could someone please highlight what am I missing?
Upvotes: 0
Views: 27
Reputation: 25408
use en-GB
instead of en-US
let options = {
hour12: false,
timeZone: "America/Chicago",
timeStyle: "short",
};
let myDate = new Date("2021-06-07T05:46:00.000Z").toLocaleTimeString(
"en-GB",
options
);
console.log(myDate);
Upvotes: 2