I'm getting the infamous PHP timezone error:

PHP Warning: PHP Startup: 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/Moscow' for 'MSK/3.0/no DST' instead in Unknown on line 0

I did use date.timezone indeed, setting it to Europe/Berlin and Europe/Vilnius and then 'Europe/Vilnius' in php.ini but nothing seems to work.

Using PHP 5.3.0 with Apache 2 server on Ubuntu Linux 9.04

Besides, I'm getting this error at the time Apache with PHP starts, it is probably caused by one of plugins, maybe pecl... anyway, how could I set that timezone properly? Thanks in advance!


On a per-script basis without using php.ini (extra useful if it was shared hosting), include this in a header or wherever relevant:

echo date_default_timezone_get(); //Before
echo date('Y-m-d H:i:s T'); //After
| improve this answer | |
  • 2
    Could you be more specific about where you are making that setting? The OP specifically mentions php.ini so he can set this globally. Would be a great answer if it had a little more explanation. – dunxd Sep 20 '12 at 10:33
  • Fixed and yeah; it isn't global but it's a practical solution but not permanent. – Alastair Sep 21 '12 at 13:13

I got it working after complete apache & php reinstall from source. Must have been some LAMPP bug, probably.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.