Hi,
There is one place in my application that I am using date() function. On servers where "date.timezone" is not set in the php.ini file, this function gives the following warning:
Now, since this application will be distributed and I can't control all servers, I am trying to find the best way to handle this.Code:Warning: date() [function.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.
Here is the options I could find:
1. Suppress the warning by "@date()".
2. Check if "date.timezone" value is not set in php.ini and suppress the warning accordingly:
3. Check if "date.timezone" value is not set in php.ini and set a default timezone, which is not I want because the application will be used all around the world:Code:$timezone = ini_get('date.timezone'); if (empty($timezone)) { echo @date('Y'); } else { echo date('Y'); }
Please let me know if you have any ideas about this. Thanks.Code:$timezone = ini_get('date.timezone'); if (empty($timezone)) { date_default_timezone_set('Europe/London'); } echo date('Y');



Reply With Quote

Bookmarks