8.4.2 How to set 24 hour format for datetime picker?
PermalinkIt shows a 24 h format in Russian locale but it's only a 12 h format in English.
How can I force it to 24 h regardless of the language?
I'd like to know if the core can be overridden somehow.
Thanks for the info, but unfortunately it didn't work for me.. I changed:
$timeFormat = $dh->getTimeFormat();
TO:
$timeFormat = 24;
but I'm still seeing AM/PM on the dateform pickers - did you find another way to force 24hours?
Many thanks
I was looking through the logs (reports>logs) and see a ton of errors similar to:
public_html/concrete/vendor/punic/punic/code/Data.php:70 'en_US UNION ALL SELECT NULL,NULL,NULL-- CbQR' is not a valid locale identifier (10001)
Ideas as to what could be causing these?
As I once have investigated, it seems there is no perfect way to change the time format by sending a parameter to the method. The time format, 24 or 12, is directly fetched by "Punic" library and their respective files, which in your case should be:
- for default language (en): \concrete\vendor\punic\punic\src\data\en\calendar.php: ['timeFormats']['short']
- for Russian language (ru): \concrete\vendor\punic\punic\src\data\ru\calendar.php: ['timeFormats']['short']
The easiest way seems to edit this core file: \concrete\src\Form\Service\Widget\DateTime.php > datetime() method and set $timeFormat= 24 manually, so it always displays 24h format short of considering current locale the user is browsing. Since it is not a good practice to edit a core file, you might want to investigate whether this file is overridable before directly editing it.
P.S: It might be a good idea to add an extra parameter to datetime() method, so the format can be altered in these cases.