MDN documentation for toLocaleTimeString() indicates that the hourCycle
and hc
options have four possible values: "h11"
, "h12"
, "h23"
, & "h24"
.
Two of the possible values strike me as super obvious (i.e. "h12"
and "h24"
), but the other two, I have no idea what they do and my duckduckfoo/googlefoo is failing me!
What are the "h11"
and "h23"
values representing?
My best guess is that they are some type of 0
vs 1
derivations of "h12"
and "h24"
, but the underlying date stamp is still the same, and the value logged is the same, so if this is it, where is the difference?
This should be documented, or at least linked to, on MDN's toLocalTimeString page or ECMAScript's toLocalTimeString page, but it's not. It also really strikes me as something that should be simple to figure out, and yet I’m not seeing the difference, and it’s now crawling under my skin!
const now = new Date();
console.log('hourCycle: h11', now.toLocaleTimeString('en-US', { hourCycle: 'h11' }))
console.log('hourCycle: h12', now.toLocaleTimeString('en-US', { hourCycle: 'h12' }))
console.log('hourCycle: h23', now.toLocaleTimeString('en-US', { hourCycle: 'h23' }))
console.log('hourCycle: h24', now.toLocaleTimeString('en-US', { hourCycle: 'h24' }))
toLocaleTimeString
or it's option (granted, I normally use MDN, so I'm a little out of water). – Theodorah24
is default: github.com/moment/luxon/issues/726 whenhour12: false
is specified – Hallucinatory