WordPress.org

Ready to get started?Download WordPress

Forums

Php 5.3.0 & WP 2.8 (It is not safe to rely on the system's timezone) (33 posts)

  1. jassu
    Member
    Posted 5 years ago #

    After upgrading webservers php 5.2.9 to new stable 5.3.0 wordpress started to give following errors to every page:

    ***
    Warning: strtotime() [function.strtotime]: 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/Helsinki' for 'EEST/3.0/DST' instead in /path/to/my/www/wp-includes/functions.php on line 35

    Warning: date() [function.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/Helsinki' for 'EEST/3.0/DST' instead in /path/to/my/www/wp-includes/functions.php on line 43

    Warning: strtotime() [function.strtotime]: 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/Helsinki' for 'EEST/3.0/DST' instead in /path/to/my/www/wp-includes/functions.php on line 35

    Warning: date() [function.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/Helsinki' for 'EEST/3.0/DST' instead in /path/to/my/www/wp-includes/functions.php on line 43
    ***

    Problem with php 5.3.0 or wordpress 2.8? I changed the timezone setting from properties to Europe-Helsinki (was GMT +3) without help.

  2. conceptify
    Member
    Posted 5 years ago #

    I have run into the same issue and here is what I did to resolve it:

    In /wp/wp-includes/functions.php

    Add the following before the first function:

    date_default_timezone_set('UTC');

    Not sure if this is the best place to put this but some of the other places I tried it didn't work or only worked for certain parts of WordPress

  3. jassu
    Member
    Posted 5 years ago #

    That seems to work, thought it's quite ugly fix :D

  4. Dan.LaSota
    Member
    Posted 5 years ago #

    Another way to approach this is to let php know what your time zone is. You can edit your php.ini file and put in the following line:

    date.timezone = "America/Anchorage"

    You can find valid time zone strings at http://nl3.php.net/manual/en/timezones.php

  5. peter-b
    Member
    Posted 5 years ago #

    Any update on this? I tried Dan's fix but without success - I have just reverted back to PHP 5.2.8

  6. mrmist
    Forum Janitor
    Posted 5 years ago #

    Dan LaSota posted the fix. This is a PHP change, not a WordPress change. PHP 5.3.0 needs the date.timezone ini entry setting properly in order to avoid the warning being sent out.

    Prior to PHP 5.3.0, the line existed in the PHP ini but was generally commented out.

    Depending on your setup you may need to restart your web services after making the change.

  7. Dan.LaSota
    Member
    Posted 5 years ago #

    You should, of course, use the time zone you want, not necessarily "America/Anchorage". Also I just installed apache/mysql/php3.0 on an entirely new machine, ran into the same problem and after adding the
    date.timezone = "America/Anchorage"
    to my php.ini file the problem went away.

  8. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    If you don't have access to the php.ini, adding this to the top of the wp-config.php file will do much the same thing:

    date_default_timezone_set('America/Chicago');

    Use whatever timezone is appropriate for you, of course. List is here:
    http://us3.php.net/manual/en/timezones.php

    Note that this will not affect the timezone setting in WordPress. In fact, WordPress will override it. It just doesn't set it early enough to avoid this warning. The best way is still to have a default set in the php.ini file.

  9. mrmist
    Forum Janitor
    Posted 5 years ago #

    The best way is still to have a default set in the php.ini file.

    Indeed, and if a web host has provided 5.3.0 then they should really have put the timezone setting into the php.ini, as the lack of it would affect all their users. I'd be tempted to open a ticket if that were the case.

  10. peter-b
    Member
    Posted 5 years ago #

    Thank you - I'll try it later.

  11. peter-b
    Member
    Posted 5 years ago #

    Okay, my /etc/php.ini file looks like this
    <----snip

    [Date]
    ; Defines the default timezone used by the date functions
    ;
    ;
    date.timezone = "Europe/London"
    ;
    ;date.default_latitude = 31.7667
    ;date.default_longitude = 35.2333

    ;date.sunrise_zenith = 90.583333
    ;date.sunset_zenith = 90.583333

    snip----->

    I have restarted Apache - still get

    Warning: strtotime() [function.strtotime]: 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/London' for 'BST/1.0/DST' instead in /var/www/html/blog/wp-content/plugins/comment-timeout/comment-timeout.php on line 342

    repeated with different line numbers.

    Reverting back to 5.2.8!

  12. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    peter-b: Make sure that there's not another php.ini file somewhere. mod_php for Apache frequently has its own php.ini that's not in /etc.

  13. fukiburi
    Member
    Posted 5 years ago #

    thanks for posting the solution with the php.ini! it solved my problem perfectly :)

  14. ymasood
    Member
    Posted 5 years ago #

    conceptify thanks and your solution worked!

  15. crayaco
    Member
    Posted 5 years ago #

    Another way to approach this is to let php know what your time zone is. You can edit your php.ini file and put in the following line:

    date.timezone = "America/Anchorage"

    You can find valid time zone strings at http://nl3.php.net/manual/en/timezones.php

    Tried this and it fixed my problem. Thanks for solution.

  16. stephaniemdavis
    Member
    Posted 5 years ago #

    I am running XAMPP on a USB stick and encountered the same problem as mentioned above. Here's what I did to fix it:

    First, I changed the “time zone” in my WordPress ‘Settings’ to ‘America/New York’.

    Next, I went to my XAMPP control panel and selected the ‘Setup’ button. For reasons unknown to me, I eventually reached a screen that automatically changed the “php.ini” setting to reflect the WordPress setting change mentioned above.

    Lastly, I shutdown both MySQL and Apache in my XAMPP control panel, restarted both and logged into my WordPress admin panel. Voila!!! everything is now fine.

  17. peter-b
    Member
    Posted 4 years ago #

    Ok - I have only one PHP.ini file that I can find on my system (locate php.ini) which has been edited as above. I have rebooted the system after installing php5.3 - and I still get the same errors.

    The timezone in WordPress settings is set to London (although it still shows times as BST and DST - is that correct?

    Looks like I'll be sticking with php 5.2.8

  18. simple cart
    Member
    Posted 4 years ago #

    thank for this guide
    :=)

  19. zzzaccount
    Member
    Posted 4 years ago #

    Thanks conceptify,
    Modifying the functions.php didi it for me

  20. patsar
    Member
    Posted 4 years ago #

    Thanks a lot.
    Editing the php.ini solve the problem.

  21. sarge117
    Member
    Posted 4 years ago #

    Thank you so much, this one php.ini line solved my problems, and i am using xampp on a usb stick.

    FYI php.ini on xampp >

    /xampp/php/php.ini

    ctrl+F > find "date.t"

    delete the whole line [including ;] < very important

    replace with: date.timezone = "Europe/London"

    [or another timezone]

    dont forget to restart xampp!

    Cheers!

  22. web-runner
    Member
    Posted 4 years ago #

    conceptify It works! Regards from Buenos Aires

  23. Rhand
    Member
    Posted 4 years ago #

    @ Conceptify Thanks!

    date_default_timezone_set('Europe/Moscow');

    in wp-includes/functions.php did the trick. Still, it would be better to have used a fix that did not involve changing a WordPress core file.
    The timezone indicated in my php.ini seems to be the correct one

    date.timezone = "Europe/Moscow"

    But WordPress does not want to rely on the System's timezone..

  24. jboontje
    Member
    Posted 4 years ago #

    Thanks a bunch Conceptify, I almost freaked out as I never updated WordPress before.

    How can they forget about such an easy line of code on an upgrade.. seriously.

  25. iifolioDesign
    Member
    Posted 4 years ago #

    By editing the php.ini works beautiful.

    Thanks so much

  26. yablokitay.ru
    Member
    Posted 4 years ago #

    Thanks

  27. kckal
    Member
    Posted 4 years ago #

    i do not see an explanation as to why the editing php.ini would not fix it. i agree, changing functions.php or even the config file is not ideal. can anyone shed light on that please?

  28. Lex@
    Member
    Posted 4 years ago #

    Thanks a lot guys for information i've fixed the problem date.timezone = "Europe/Moscow"

  29. randell
    Member
    Posted 4 years ago #

    I do not understand why it is better to modify php.ini instead of adding the date_default_timezone_set() function in the WordPress core. From the description of date_default_timezone_get(), the highest in the preference is "Reading the timezone set using the date_default_timezone_set() function (if any)". And it makes sense since it would not be wise to rely on the system's php.ini settings for the timezone. Yes, it would be better if the directive for date.timezone is set but WordPress, or any PHP project, should rely on the directive being set. It might be better to add a configurable variable with a default value set for the date_default_timezone_set() function.

  30. I do not understand why it is better to modify php.ini instead of adding the date_default_timezone_set() function in the WordPress core.

    You can do what you like (as I'm sure you know) but this us a PHP 5.3.0 issue and not a WordPress issue. Putting it into php.ini, if you can, sets the timezone for your PHP install.

    If you can't edit php.ini, putting it into WordPress is a good tactical work around.

    And it makes sense since it would not be wise to rely on the system's php.ini settings for the timezone.

    Why not? Relying on the system timezone never let me down before. I'm running php 5.3.2 and echo date(DATE_RFC822); works fine for me. I didn't set the timezone explicitly anywhere.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.