LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   PHP Data/Timezone Problems, Slackware 14.0, php-5.4.7-x86_64-1 (https://www.linuxquestions.org/questions/slackware-14/php-data-timezone-problems-slackware-14-0-php-5-4-7-x86_64-1-a-4175433722/)

tronayne 10-23-2012 01:46 PM

PHP Data/Timezone Problems, Slackware 14.0, php-5.4.7-x86_64-1
 
I have a PHP application (PHPGedView) that yammers at me:
Quote:

ERROR 2: date(): 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.
0 Error occurred on in function date
1 called from line 356 of file session.php in function require_once
2 called from line 75 of file config.php in function require
3 called from line 29 of file index.php
I already know that date.timezone must be set in /etc/httpd/php.ini and have done so:
Code:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "America/New_York"

; 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

Running phpinfo.php with the above shows me:
Code:

date/time support        enabled
"Olson" Timezone Database Version        2012.3
Timezone Database        internal
Default timezone        UTC

Directive        Local Value        Master Value
date.default_latitude        31.7667        31.7667
date.default_longitude        35.2333        35.2333
date.sunrise_zenith        90.583333        90.583333
date.sunset_zenith        90.583333        90.583333
date.timezone        America/New_York        America/New_York

Now, the default.timezone is set to "America/New York" but the value shows up as UTC here and that causes the problem in the application.

I have tried setting the value to "America/Detroit" which phpinfo.php displays as
Code:

date/time support        enabled
"Olson" Timezone Database Version        2012.3
Timezone Database        internal
Default timezone        America/Detroit

Directive        Local Value        Master Value
date.default_latitude        31.7667        31.7667
date.default_longitude        35.2333        35.2333
date.sunrise_zenith        90.583333        90.583333
date.sunset_zenith        90.583333        90.583333
date.timezone        America/Detroit        America/Detroit

but application displays the same nonsense (albeit in a slight different format) about
Quote:

ERROR 2: date(): 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.
0 Error occurred on in function date
Uh... WTF?

My hardware clock is set to UTC and I define US/Eastern when setting the system timezone.

Is there something I've missed?

astrogeek 10-23-2012 03:09 PM

I think this applies to you.

http://sourceforge.net/tracker/?func...56&atid=634867

tronayne 10-23-2012 04:03 PM

Thanks for the link but... I've already done all that, no joy in Mudville.

I'm beginning to suspect that PHPGedView is kaput.

Sigh.

tronayne 10-24-2012 10:25 AM

All right, got it more-or-less fixed (I blew away the application and re installed it).

You pretty much have to edit /etc/httpd/php.ini to define your date.timezone (PHP will no longer use the system date and you'll get all the errors if you use any of the date functions).

I happen to be in the U.S. eastern time zone and, even though there is a setting for Detroit (I'm in northern Michigan) I just chose to use the New York setting:
Code:

vi /etc/httpd/php.ini
<find the string date.timezone>
date.timezone = "America/New_York"

Don't forget to replace blanks in a place name with underscores.

I also un-commented the latitude, longitude and zenith settings but that doesn't appear to be necessary.

The reference material is found at http://www.php.net/manual/en/class.d...stants.america, including a list of the supported time zones (at the left edge of the web page).

When you change /etc/httpd/php.ini, you'll need to restart the httpd daemon.

You can then use a phpinfo.php file to display the Date values.

Hope this helps some.


All times are GMT -5. The time now is 06:14 PM.