2

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!

2 Answers 2

1

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

<?php
echo date_default_timezone_get(); //Before
date_default_timezone_set('Europe/Berlin');
echo date('Y-m-d H:i:s T'); //After
?>
2
  • 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, 2012 at 10:33
  • Fixed and yeah; it isn't global but it's a practical solution but not permanent.
    – Alastair
    Sep 21, 2012 at 13:13
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .