24hr format instead of AM/PM in Europe

I have an additional observation

With Firefox on Windows - setting language to Danish or British English - the time is shown in 24 hour

With Google Chrome on windows - setting language to Danish or British English - still shows am/pm

Setting Google Chrome to Danish makes Home Assistant show the UI in Danish so it does understand the language property. But is still shows am/pm.

There is something wrong with the detection of these regional settings that depends on browsers.

One more observation
24 hour format is correct on my iPad which is set to British English
Google chrome on a Windows machine at home shows 24 hour format - it is set to British English in both browser and Windows itself
Google Chrome on a Windows machine at work showed 12 hour format. Browser set to British English. Windows was US English with 24 hour dd/mm/yyyy settings.
I changed the Windows to British English and rebooted the machine. Then the display is in 24 hour - finally!
So it does not matter what the browser it set to with Google Chrome. The OS below as to be in a language that sets 24 hour clock.

I hope a lot of people can use this work around

I still maintain my view that a setting like time and date format should be possible to set in the configuration. You cannot assume that people will always want the defaults from the language setting.

3 Likes

I fully agree to have a configuration setting for date and time format. I can’t get it to work in 24h format. I tried every setting I could find (Windows, browser, languages, etc) and it still does not work. I’m really getting crazy from this stupid dependency on various settings in other places!!! Please make it configurable within HA.

4 Likes

Another +1 here. I was suprised to find that this is not configurable anywhere.
It can’t be right, that users need to change the locale of their machine/browser to get the desired date format to display.
Implicitly setting the date format on the browsers display language is a bad choice. The browsers language value provides information about a client systems language, but not about its location or the common use of time format in said location.
It is obvious to me that users should be able to set/override the date and time format in the settings.

3 Likes

Did anyone manage to fix this? I have my phone set to English (Netherlands) and in NL we use 24 hour clocks, but I still get am/pm. Even if I set my language to Dutch in Homeassistant I still get am/pm. It’s a very strange behaviour.

1 Like

I have more observations on this.

On both Windows and Linux I see the same behavior with Google Chrome. You can set the language to anything you like and Home Assistant still shows am/pm anywhere.

You have to change the language of the OS itself!!!. My guess is that this mainly hits people running English because if you want all in German your OS is probably German too. Change Windows or Linux from default English which is US English to specifically British English (English UK. Or whatever variant of English you belong to. I am Danish but always run OS in English.

When I set the OS to UK English AND Chrome to same then it almost works. Most user interfaces now change to 24 hour clock.

Except. The history page is 24 hour but the hover over pop-ups are still am/pm. That is a bug!
The logbook is always am/pm no matter what I try. Also a bug.

But all the Lovelace features I can see seems to be 24 hour once the OS is UK English. Try that. Not perfect but at least much better until someone with time and energy fixes the bugs

3 Likes

The fundamental problem seem to be an assumption that regional settings, language, and country of residence are 98% connected (not 100% as Home Assistant allows configuring temperature and unit system).

I live in Ireland which use 12h clock and weeks starting on Sunday (mostly), but I grew up in Denmark which use 24h clock and week starting on Monday. That doesn’t mean I want any user interface to use Danish as translations generally just make it harder to understand.

I don’t know how many Home Assistant instances are used by people with multiple regional preference requirements, but I suspect not many so allowing just setting things like 24 hour clock in Home Assistant configuration rather than relying on browser side configuration seem like a reasonable simple way of fixing this problem for people who care.

I unfortunately (in this case) don’t know anywhere near enough Javascript to look into how hard this is to fix.

PS. I regularly point out this same problem in applications developed at work - it’s by no mean a Home Assistant specific problem.

Yeah… that’s not a simple change. That’s a huge change. And for little benefit. Un-linking the datetime library from the langauge of the OS is a huge undertaking. Hell it’s taken 30 years to get here and it still doesn’t work properly for 100% of the cases. Not to mention, that’s not even controlled by HA. That’s a built-in for python. Your best option is to create your own language profile in your OS with the correct language and time format.

Reading the thread above, people seems to indicate it’s client side / browser / Javascript controlled.

Am I reading you right that it’s actually based on server side locale, so I just need to find a big enough hammer fix locale there?

Any tip on roughly where this is controlled would be much appreciated. I’m perfectly happy to read code, but without a starting point there is a lot of code to read.

No it is your client OS in which you run your browser that need to be a locale that supports 24 hour. It seems the many browsers present the locale of the OS. The language setting in the browser only sets which language to display. But all the locale stuff comes from OS.

Petro - I doubt it is a huge change. I have been contributing to two different wiki’s (Perl based with OSS javascript fronts ends) and we managed. You say for little benefit. Yes. You are american. But this community seems pretty international from what I can tell and it means a lot to the rest of us that you do not have to mentally translate everything related to time and dates.

To get the behavior he wanted, it would be a large change. Your 2 issues seem merely bugs that would be small changes. Requesting the ability to change between 24 and 12 formats everywhere is a large change. Specially seeing that half of the interface is old and the other half is lovelace/polymer. It’s not a simple change by any means. Not to mention people will think that the config will also work in 12 or 24 hour.

I never had this problem (24H/12H) before but now I am running 0.90.1, I noticed that the time displayed has changed from 24H to AM/PM (I do not know in which version the change occured)… but when I modify the time, it is in a 24H format, than back to AM/PM to display it after the change… My browser and operating languages are French ! Bug or new parameter to set ? It seems that this behavior is only for chrome browser … It is ok with Edge…

I found the solution: I cleared the Google Chrome browser history… now the dates are correctly displayed…

I’ve cleared the cache, changed the web browser and OS regional setting and still get the damn AM/PM crap.

1 Like

Same. Very need force override!

If i change my language it turns to the correct 24H format, only thing is that i prefer english instead of Dutch. So now i would be stuck with that AM/PM just because its set to english? Did someone find the correct way for this? My browser is set to dutch but language in the profile is leading as far as i can tell. (not the end of the world if not possible)

It is bugged. And they dont care about it. Bug has been there for a long time. For me i can see 24h format in history tab, but all cards are in 12h format. I do use english too.

This is a javascript thing and not python. Test this in your browser:
alert(new Date().toLocaleTimeString());
You will get AM/PM.
Test this: alert(new Intl.DateTimeFormat().resolvedOptions().locale);
Test this in a console: echo $LANG
Do you get en_US?
Maybe this is the reason why time values are formatted with AM/PM by javascript.
Maybe your system is set to en_US. Try setting it to en_GB.
Or change the browser language. In Firefox: Preferences-Language (Choose the languages used to display menus).

Don’t waste your breath. I’ve tried explaining this many times over and everyone screams bug. Location & Language drive it all.

The bug is that people don’t know what happens. If HA would display the LANG setting of the system, then people know why the time format is american. And there could be a warning if the local setting in the backend (=HA) is different then that from the browser.