Timezone information

Jump to: navigation, search
Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable. It's just kept for historical and informative purposes.

Note: As of Moodle 2.9 (see MDL-49684 for more details), the older setting and button to allow you to update time zone codes from Moodle.org has been replaced with standard PHP date and time code. If your PHP version is over 6 months old, time zone data should be updated using the PECL timezonedb package. For more information about how to handle dates and times, please visit the Time API docs.

Timezone information in Moodle is manually kept up-to-date with the IANA's Olson database as new information is released. This page contains information on this process.

Getting new information from the IANA

There are two ways you can get information from the IANA - by downloading the latest release and manually concatenating specific files together, or by running a Python script built for that purpose.

Manual retrieval

  • Go to the IANA's Time Zone Database site and get the latest data file (e.g. tzdata*****.tar.gz).
  • Extract the file to an appropriate location.
  • Create a new text file, naming it olson.txt and concatenate the following files in the following order:
    • africa
    • antarctica
    • asia
    • australasia
    • europe
    • northamerica
    • southamerica
    • etcetera

Automatic retrieval

Importing information into Moodle

  • Place the generated olson.txt file into {dataroot}/temp/olson.txt, where {dataroot} is the path to your Moodle's moodledata folder
  • In a browser, go to Site administration -> Location -> Update timezones and confirm
    • The contents of your timezone database table will be flushed and regenerated from the olson.txt

Exporting information

  • Using a DB admin tool (e.g. phpMyAdmin, pgadmin3), generate a CSV file from your timezone database table with the following settings:
    • commas as field separators
    • non-quoted values
    • unix line feeds
    • first line as field names
  • Replace {moodleroot}/lib/timezone.txt with the contents of the CSV file
  • Commit to git and fill out the tracker fields as necessary

The integrators have a separate process that copies the {moodleroot}/lib/timezone.txt out of HEAD to https://download.moodle.org/timezone/, so you shouldn't have to do anything more.