Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] php5.5: "date.timezone" in php.ini is ignored
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
hoacker
Guru
Guru


Joined: 04 Aug 2007
Posts: 498
Location: Bürstadt, Germany

PostPosted: Sun Oct 12, 2014 7:29 pm    Post subject: [solved] php5.5: "date.timezone" in php.ini is ign Reply with quote

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:
Code:
[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:
Code:
# 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
Back to top
View user's profile Send private message
Pearlseattle
Apprentice
Apprentice


Joined: 04 Oct 2007
Posts: 162
Location: Switzerland

PostPosted: Fri Oct 24, 2014 8:46 pm    Post subject: Reply with quote

Your "# php -i " is executed from the CLI.
What does...
Code:
eselect php list apache2

...show?
Back to top
View user's profile Send private message
freke
Guru
Guru


Joined: 23 Jan 2003
Posts: 491
Location: Somewhere in Denmark

PostPosted: Sat Oct 25, 2014 6:26 am    Post subject: Reply with quote

Dunno if it matters but I use
Code:
date.timezone = Europe/Berlin
(ie. no quotes) and that seems to work fine for me :)
Back to top
View user's profile Send private message
hoacker
Guru
Guru


Joined: 04 Aug 2007
Posts: 498
Location: Bürstadt, Germany

PostPosted: Sun Oct 26, 2014 12:09 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
neofutur
n00b
n00b


Joined: 18 Jun 2006
Posts: 21
Location: France

PostPosted: Mon Oct 27, 2014 9:48 am    Post subject: Reply with quote

Pearlseattle wrote:
Your "# php -i " is executed from the CLI.
What does...
Code:
eselect php list apache2

...show?


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

Code:
<?php
 phpinfo();

?>

_________________
http://bitcoin.gw.gd-http://ww7.pe-http://waisse.org
Back to top
View user's profile Send private message
hoacker
Guru
Guru


Joined: 04 Aug 2007
Posts: 498
Location: Bürstadt, Germany

PostPosted: Mon Oct 27, 2014 10:15 am    Post subject: Reply with quote

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

Code:
<?php
 phpinfo();

?>


Right. There's a little quote from the output in my first post.
Back to top
View user's profile Send private message
neofutur
n00b
n00b


Joined: 18 Jun 2006
Posts: 21
Location: France

PostPosted: Mon Oct 27, 2014 12:34 pm    Post subject: Reply with quote

hoacker wrote:
neofutur wrote:
to check your apache install just create a small php webpage with

Code:
<?php
 phpinfo();

?>


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


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

Code:
Default timezone    Europe/Berlin


or not
_________________
http://bitcoin.gw.gd-http://ww7.pe-http://waisse.org
Back to top
View user's profile Send private message
hoacker
Guru
Guru


Joined: 04 Aug 2007
Posts: 498
Location: Bürstadt, Germany

PostPosted: Mon Oct 27, 2014 12:52 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
hoacker
Guru
Guru


Joined: 04 Aug 2007
Posts: 498
Location: Bürstadt, Germany

PostPosted: Mon Oct 27, 2014 10:23 pm    Post subject: Reply with quote

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:

Code:
[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.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum