# [solved] php5.5: "date.timezone" in php.ini is ignored

## hoacker

Hi.

This problem is driving me nuts and I have no idea how to fix this. As far as I can see, my settings in php.ini are correct and I should not get the following warnings when apache serves pages created with php:

 *Quote:*   

> Warning: phpinfo(): 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 the timezone 'UTC' for now, but please set date.timezone to select your timezone.

 

from phpinfo():

 *Quote:*   

> Loaded Configuration File 	/etc/php/apache2-php5.5/php.ini 

 

snippet from /etc/php/apache2-php5.5/php.ini:

```
[Date]

; Defines the default timezone used by the date functions

; http://php.net/date.timezone

date.timezone = "Europe/Berlin"

; http://php.net/date.default-latitude

;date.default_latitude = 31.7667

; http://php.net/date.default-longitude

;date.default_longitude = 35.2333

; http://php.net/date.sunrise-zenith

;date.sunrise_zenith = 90.583333

; http://php.net/date.sunset-zenith

;date.sunset_zenith = 90.583333

```

php -i shows the correct timezone:

```
# php -i | grep timezone

Default timezone => Europe/Berlin

date.timezone => Europe/Berlin => Europe/Berlin

```

I have no idea what else to check. I know that I could use the php function "date_default_timezone_set()" but I don't want to modify third party code.

Edit: Seems to be a problem with php 5.5 as 5.3 works fine.Last edited by hoacker on Mon Oct 27, 2014 10:23 pm; edited 2 times in total

----------

## Pearlseattle

Your "# php -i " is executed from the CLI.

What does...

```
eselect php list apache2
```

...show?

----------

## freke

Dunno if it matters but I use 

```
date.timezone = Europe/Berlin
```

 (ie. no quotes) and that seems to work fine for me  :Smile: 

----------

## hoacker

Thank you for your answers.

@Pearlseattle: When I tried to fix that problem, only php-5.5 was installed. Eselect did show php5.5 as selected php slot. I kept php.ini for apache and cli the same concerning the timezone settings. I also removed php.ini files for other versions of php just to avoid any confusion. 

@freke: I've tried the zone string without quotes, single quotes and double quotes. No success with any variant.

Later I've added the corresponding php_value in some vhosts.d/*.conf files and I could get rid of this problem:

 *Quote:*   

> php_value "date.timezone" "Europe/Berlin"

 

Meanwhile I reverted to php-5.3 for other reasons. There's no such problem with 5.3.

----------

## neofutur

 *Pearlseattle wrote:*   

> Your "# php -i " is executed from the CLI.
> 
> What does...
> 
> ```
> ...

 

to check your apache install just create a small php webpage with

```
<?php

 phpinfo();

?>
```

----------

## hoacker

 *neofutur wrote:*   

> to check your apache install just create a small php webpage with
> 
> ```
> <?php
> 
> ...

 

Right. There's a little quote from the output in my first post.

----------

## neofutur

 *hoacker wrote:*   

>  *neofutur wrote:*   to check your apache install just create a small php webpage with
> 
> ```
> <?php
> 
> ...

 

the important part here is not the warning, but the info it gives in the date section :

```
Default timezone    Europe/Berlin
```

or not

----------

## hoacker

Sorry, I have no longer php-5.5 installed to check the output of phpinfo(). But I'm pretty sure the timezone was not Europe/Berlin. There was a warning above that section that the timezone was not set.

----------

## hoacker

OK, there seems to be some interest in this problem. I reinstalled 5.5, eselected it and finally found the culprit. Here's a snippet from php.ini:

```
[PHP]

;;;;;;;;;;;;;;;;;;;

; Quick Reference ;

;;;;;;;;;;;;;;;;;;;

 error_reporting E_ALL & ~E_DEPRECATED & ~E_STRICT

;;;;;;;;;;;;;;;;;;;;

; Language Options ;

;;;;;;;;;;;;;;;;;;;;

engine = On

short_open_tag = Off

asp_tags = Off

precision = 14

output_buffering = 4096

zlib.output_compression = Off

implicit_flush = Off

unserialize_callback_func =

serialize_precision = 17

disable_functions =

disable_classes =

zend.enable_gc = On

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Error handling and logging ;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

display_errors = On

display_startup_errors = On

log_errors = On

log_errors_max_len = 1024

ignore_repeated_errors = Off

ignore_repeated_source = Off

report_memleaks = On

track_errors = On

html_errors = On

;;;;;;;;;;;;;;;;;;;

; Module Settings ;

;;;;;;;;;;;;;;;;;;;

[Date]

date.timezone = "Europe/Berlin"

```

Please note the two lines with value "error_reporting". The first one in the "quick reference" section is missing the "=". For some reason I chose to put that line there instead of the "error handling and logging" section where you can find the correct line commented out. After adding the missing "=" the timezone is set correctly.

When the "=" is missing in the "error handling and logging" section the timezone is still correct. Why that?

Both php-5.3 and php-5.5 show the same behaviour.

----------

