24-hour clock instead of 12-hour

24-hour clock instead of 12-hour

by William Merrifield -
Number of replies: 5
We run an online program with students throughout the Arab world. Our tutors are having a problem determining if a student turned in an assignment on time because it is not clear whether they turned in the assignment at 8:00 am or 8:00 pm. The simple solution would be to change the Moodle clock to a 24 hour format across the whole site, but I can't figure out how to do this.

We use both Arabic and English in our site.

Can someone describe the process where I can change the clock across the whole site to display a 24-hour format?

Thank you.
Average of ratings: -
In reply to William Merrifield

Re: 24-hour clock instead of 12-hour

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

have a look at the localized strings in lang/en/langconfig.php

$string['strftimedate'] = '%d %B %Y';
$string['strftimedatefullshort'] = '%d/%m/%y';
$string['strftimedateshort'] = '%d %B';
$string['strftimedatetime'] = '%d %B %Y, %I:%M %p';
$string['strftimedatetimeshort'] = '%d/%m/%y, %H:%M';
$string['strftimedaydate'] = '%A, %d %B %Y';
$string['strftimedaydatetime'] = '%A, %d %B %Y, %I:%M %p';
$string['strftimedayshort'] = '%A, %d %B';
$string['strftimedaytime'] = '%a, %H:%M';
$string['strftimemonthyear'] = '%B %Y';
$string['strftimerecent'] = '%d %b, %H:%M';
$string['strftimerecentfull'] = '%a, %d %b %Y, %I:%M %p';
$string['strftimetime'] = '%I:%M %p';

Changing these values using Site administration ► Language  ► Language customisation can help.

In reply to Renaat Debleu

Re: 24-hour clock instead of 12-hour

by William Merrifield -

Thank you Renaat,

Do you know exactly what I should change these values to? I have a bit of confusion as to what I should put in the place of these values.

In reply to William Merrifield

Re: 24-hour clock instead of 12-hour

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

The php manual learns:

  • a Lowercase Ante meridiem and Post meridiem am or pm
  • A Uppercase Ante meridiem and Post meridiem AM or PM
  • g 12-hour format of an hour without leading zeros 1 through 12
  • G 24-hour format of an hour without leading zeros 0 through 23
  • h 12-hour format of an hour with leading zeros 01 through 12
  • H 24-hour format of an hour with leading zeros 00 through 23

So replace all g into G and h into H in your Arab and English language strings to have a 24 hour format.

In reply to Renaat Debleu

Re: 24-hour clock instead of 12-hour

by William Merrifield -

Thank you again Renaat. Unfortunately none of the settings in lang/en/langconfig.php use the lowercase g or h.

I am trying to figure out how to change the strftime settings so it displays a 24-hour clock. My settings are currently set like this:

core_langconfig          strftimedate                            %d %B %Y
core_langconfig          strftimedatefullshort              %d/%m/%y
core_langconfig          strftimedateshort                   %d %B
core_langconfig          strftimedatetime                    %d %B %Y, %I:%M %p
core_langconfig          strftimedatetimeshort            %d/%m/%y، %H:%M
                                                                                          %d/%m/%y, %H:%M

core_langconfig          strftimedaydate                      %A, %d %B %Y
core_langconfig          strftimedaydatetime               %A, %d %B %Y, %I:%M %p
core_langconfig          strftimedayshort                     %A, %d %B
core_langconfig          strftimedaytime                      %a, %H:%M
core_langconfig          strftimemonthyear                 %B %Y
core_langconfig          strftimerecent                         %d %b, %H:%M
core_langconfig          strftimerecentfull                   %a, %d %b %Y, %I:%M %p

core_langconfig          strftimetime                            %I:%M %p

How to change what is where I'm confused.

In reply to William Merrifield

Re: 24-hour clock instead of 12-hour

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Use Site administration ► Language  ► Language customisation ► Open Arabic language pack

select in Show strings of these component: langconfig.php

Click on Show strings

There should be a g or h that you can change into G or H.

If not, you are working with a plugin that is not respecting the Moodle language configuration...

Average of ratings: Useful (1)