TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Crazy Error... Fix it? (http://www.talkphp.com/absolute-beginners/2320-crazy-error-fix.html)

Aaron 02-23-2008 11:13 PM

Crazy Error... Fix it?
 
ERROR MESSAGE: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable 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 'America/Denver' for 'MST/-7.0/no DST' instead

How do I fix that? Like, server setting-wise. (if thats the problem)

Gareth 02-23-2008 11:31 PM

Can we see the code please?

Aaron 02-23-2008 11:53 PM

[php]
<?php
date();
?>

SOCK 02-24-2008 12:02 AM

Sounds like it's an issue with the date.timezone setting in your php.ini config file. In PHP 5 you can set this prior to using date() (as mentioned in the error message) with date_default_timezone_set() function.

Your code is still incorrect, however. You haven't passed a formatting parameter to date().

ReSpawN 02-24-2008 12:02 AM

Did you or the server change anything about the timestamp (Apoch 1970)? If so, reset it. This is a totally not common error.

Alan @ CIT 02-26-2008 12:24 AM

1 Attachment(s)
Infact it is a very common error :-) PHP5 requires you to set the default timezone before using any date functions.

If you are unable to do this in your php.ini file, then you can use date_default_timezone_set() as Sock mentioned.

Example:

PHP Code:

date_default_timezone_set('Europe/London');
// ... your date() functions here ... 

Note about the default timezone requirement: PHP: date - Manual (see the Errors/Exception part)
List of supported timezones: PHP: List of Supported Timezones - Manual

And finally, attached is a PHP file with all the above timezones in an array. I use it to generate a <select> dropdown list to let the users set their own timezone.

Alan

ReSpawN 02-26-2008 06:36 PM

Awesome, another thing I didn't know. Thanks Alan


All times are GMT. The time now is 01:24 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0