Javascript -- Detect if user's locale are set to use 12-hour or 24-hour time format Javascript -- Detect if user's locale are set to use 12-hour or 24-hour time format google-chrome google-chrome

Javascript -- Detect if user's locale are set to use 12-hour or 24-hour time format


It's been a few years since this was last answered and a few technologies have been introduced to solve the issue. One such technology is Intl.DateTimeFormat, which provides a wealth of information about date formats for various locales.

console.log(new Intl.DateTimeFormat().resolvedOptions());console.log(new Intl.DateTimeFormat().resolvedOptions().hour12);
.as-console-wrapper { max-height: 100% !important; }