Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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!

share|improve this question

2 Answers 2

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
?>
share|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
up vote 0 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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