HTML input Time state (type=time) not localised to 24-hour input format
The following HTML feature is the subject of this question.
<input type="time"> https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time
Firefox is supposed to use a 12- or 24-hour format for input depending on region settings or locale.
I think I should see a 24-hour input format. Firefox only ever presents me with 12-hour input format -- with AM/PM selectors. Chrome, by comparison, presents 24-hour input format, out of the box, as expected. Is this a localisation bug in Firefox, or am I holding it wrong?
I shall try to upload some screenshots, but in case that does not work, here is a text representation of my state.
I am on a Mac. The Mac is configured for en_AU. (I believe 24-hour clocks are used in the en_AU locale.) Just to be sure, the "Time format: 24-Hour Time" checkbox has been enabled in the Mac's Language & Region system preferences. The following command, entered at a shell, produces the desired output format.
% date +%c Sat 26 Aug 22:48:14 2023
All other applications on my computer honour this preference to the best of my knowledge.
I have the en-GB release of Firefox Nightly. Build ID is 20230825041349. Here are the relevant sections from about:support...
Application Settings Requested Locales ["en-GB"] Available Locales ["en-GB","en-US"] App Locales ["en-GB","en-US"] Regional Preferences ["en-AU"] Default Locale "en-GB" Operating System System Locales ["en-AU"] Regional Preferences ["en-AU"]
intl.regional_prefs.use_os_locales has been set to true in about:config.
Why do I still see 12-hour input formats in Firefox?
Thank you.
Modifié le
Toutes les réponses (6)
Looks somewhat similar to https://support.mozilla.org/en-US/questions/1235351 However <input type="date"> is correctly localised for me. date is fine. time is not.
I'm happy to take this to Buganizer if you think it is a bug. Thought I should ask here first.
Most locales support 12 hour time which will be preferred, only a few are exclusively 24 hour time like en_IE and en_DK.
On Linux you can change the time locale with the environment variable:
LC_TIME=en_IE.UTF-8
Thank you for your reply.
zeroknight said
Most locales support 12 hour time which will be preferred, only a few are exclusively 24 hour time like en_IE and en_DK.
Yes, I think you are right.
As noted in the OP, on Mac platforms, the system provides a specific 24-Hour Time override, which the user may enable independent from other settings. We can see how this interacts with Apple's localisation libraries. Here is a little Swift program...
import Foundation
print(DateFormatter.localizedString(
from: Date(),
dateStyle: DateFormatter.Style.none,
timeStyle: DateFormatter.Style.short))
With the 24-Hour Time override enabled in System Preferences, output is as follows.
19:09
With the 24-Hour Time override disabled in System Preferences, output is as follows.
7:09 pm
So perhaps 12-hour clocks are preferred on en-AU as you say.
I suppose the problem is that, on a Mac, Firefox does not use Apple's localisation libraries, and does not honour the 24-Hour Time override in its own implementation for this platform. (Then again, I noticed Safari suffers from the same problem on <input type="time">
elements!)
On Linux you can change the time locale with the environment variable:
LC_TIME=en_IE.UTF-8
The equivalent on this platform would be
open -na 'Firefox Nightly' --env LC_TIME=en_IE.UTF-8
or more simply
LC_TIME=en_IE.UTF-8 open -na 'Firefox Nightly'
I gave this a try but it did not seem to impart any effect on <input type="time">
elements.
Modifié le
I reconfigured the Mac for English (Ireland) and restarted Firefox. I see 24-hour input widgets now.
Application Settings Requested Locales ["en-GB"] Available Locales ["en-GB","en-US"] App Locales ["en-GB","en-US"] Regional Preferences ["en-IE","en-AU"] Default Locale "en-GB" Operating System System Locales ["en-IE","en-AU"] Regional Preferences ["en-IE","en-AU"]
This feels like a quirky workaround, but I suppose it will do for now.
LC_TIME is only supported on Linux (GTK).
- https://searchfox.org/mozilla-release/search?q=LC_TIME&path=&case=false®exp=false
- https://searchfox.org/mozilla-release/source/intl/locale/gtk/OSPreferences_gtk.cpp#31
See also hourCycle:
I have the same, or at least a related, problem.
Running Firefox under Windows, I have, on Windows, set Regional Format to English(United Kingdom), with Regional Format Data set to give date in yyyy-mm-dd (ISO 8601) format (not the default), and time as HH:mm (which I think is the default).
Looking at - on Firefox - a web page with an <input type="datetime-local"> field, as on https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local , I see the date format as dd/mm/yyyy , not yyyy-mm-dd as I would expect (as set in Windows, and appearing on other browsers) - it is using the default option for UK dates, not the ISO option I have changed it to.
Fundamental issue is that Firefox is using the default regional data setting, not the alternate option selected (in the Windows OS locale)
I think this is essentially the same as the OP has, in overiding his normal locale with a non-default option: if not then I have a different problem (beyond Windows/Mac difference)