Moodle

Default Timezone for PHP 5.3.0

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Duplicate
  • Affects Version/s: 1.7.7, 1.8.9, 1.9.5, 2.0
  • Fix Version/s: None
  • Component/s: General, Installation
  • Labels:
    None
  • Environment:
    PHP 5.3.0 - I use a Mac server with the Entropy PHP 5.3.0-3.pkg
  • Affected Branches:
    MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE

Description

If PHP 5.3.0 is installed on the Moodle server then a default timezone must be set. Otherwise you get a lot of PHP warnings when you switch on the debugging mode. The timezone can be set in the php.ini or in the config.php. A Moodle admin is rarely allowed to change the php.ini on the web server so it should be fixed in Moodle.

see also MDL-19417

Issue Links

Activity

Hide
Ralf Krause added a comment -

Here is the list of warnings

Warning: getdate(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1305

Warning: strftime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1259

Warning: getdate(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1305

Warning: mktime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/calendar/lib.php on line 976

Warning: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/calendar/lib.php on line 976

Warning: mktime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/calendar/lib.php on line 112

Warning: mktime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/calendar/lib.php on line 113

Warning: mktime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1779

Warning: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1779

Warning: mktime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1132

Warning: strftime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1259

Warning: strftime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1255

Warning: strftime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1256

Warning: strftime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1255

Warning: strftime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1256

Show
Ralf Krause added a comment - Here is the list of warnings Warning: getdate(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1305 Warning: strftime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1259 Warning: getdate(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1305 Warning: mktime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/calendar/lib.php on line 976 Warning: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/calendar/lib.php on line 976 Warning: mktime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/calendar/lib.php on line 112 Warning: mktime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/calendar/lib.php on line 113 Warning: mktime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1779 Warning: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1779 Warning: mktime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1132 Warning: strftime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1259 Warning: strftime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1255 Warning: strftime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1256 Warning: strftime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1255 Warning: strftime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Library/WebServer/Documents/moodle19/lib/moodlelib.php on line 1256
Hide
Ralf Krause added a comment -

You can set the default timezone in the config.php.

date_default_timezone_set('UTC');
If you add the timezone 'UTC' then you have to set your correct location in ''Site Administration > Location > Location settings'' because the server's local time switches to UCT with this setting.

date_default_timezone_set('Europe/Berlin');
If you add a line with your local timezone then the localtime is really the Server's local time.

I think that the config.php would be the right place only for new Moodle installations. Only for a new Moodle installation you could ask for the timezone in the installation script. In an older installation the default timezone has to be set in a different place because there are some Moodle instances where the Moodle admin can not edit the config.php.

Show
Ralf Krause added a comment - You can set the default timezone in the config.php. date_default_timezone_set('UTC'); If you add the timezone 'UTC' then you have to set your correct location in ''Site Administration > Location > Location settings'' because the server's local time switches to UCT with this setting. date_default_timezone_set('Europe/Berlin'); If you add a line with your local timezone then the localtime is really the Server's local time. I think that the config.php would be the right place only for new Moodle installations. Only for a new Moodle installation you could ask for the timezone in the installation script. In an older installation the default timezone has to be set in a different place because there are some Moodle instances where the Moodle admin can not edit the config.php.
Hide
Ralf Krause added a comment -

Okay

I tried the following PHP script and it works. It seems that PHP reads the correct timezone from the settings of Mac OS X. I got the output 'Europe/Berlin' in my normal settings for Germany and I got 'Australia/Perth' when I switch to there in the System Preferences of my iMac.

Here you can see my test script timezone.php
<?php echo 'date_default_timezone_get () : '.date_default_timezone_get (); ?>

There is no default setting in the file /usr/local/php5/lib/php.ini
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =

I hope that you will fix this problem soon.

Thanks, Ralf

Show
Ralf Krause added a comment - Okay I tried the following PHP script and it works. It seems that PHP reads the correct timezone from the settings of Mac OS X. I got the output 'Europe/Berlin' in my normal settings for Germany and I got 'Australia/Perth' when I switch to there in the System Preferences of my iMac. Here you can see my test script timezone.php <?php echo 'date_default_timezone_get () : '.date_default_timezone_get (); ?> There is no default setting in the file /usr/local/php5/lib/php.ini [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone ;date.timezone = I hope that you will fix this problem soon. Thanks, Ralf
Hide
Ralf Krause added a comment -

... and the next test ...

If I set the default timezone in the php.ini AND in the config.php at the same time then Moodle does not show anything.

Show
Ralf Krause added a comment - ... and the next test ... If I set the default timezone in the php.ini AND in the config.php at the same time then Moodle does not show anything.
Hide
Petr Škoda (skodak) added a comment -

this is a new PHP feature

Show
Petr Škoda (skodak) added a comment - this is a new PHP feature
Hide
Ralf Krause added a comment -

Hi Petr,

remember please that a Moodle administrator has no chance to correct this error messages if he is not allowed to edit config.php or php.ini.

Ralf

Show
Ralf Krause added a comment - Hi Petr, remember please that a Moodle administrator has no chance to correct this error messages if he is not allowed to edit config.php or php.ini. Ralf
Hide
Petr Škoda (skodak) added a comment -

The time zone handling needs a full rewrite in HEAD, we already have timezone specification in server configuration which may be used, we do not need any new settings.

Show
Petr Škoda (skodak) added a comment - The time zone handling needs a full rewrite in HEAD, we already have timezone specification in server configuration which may be used, we do not need any new settings.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: