Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Php warning for using date() in header.php #182

Open
mnikhil-git opened this issue Jul 15, 2013 · 2 comments
Open

Php warning for using date() in header.php #182

mnikhil-git opened this issue Jul 15, 2013 · 2 comments

Comments

@mnikhil-git
Copy link
Contributor

[Mon Jul 15 16:06:52 2013] [error] [client XXXX] PHP Warning: 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 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/ganglia/header.php on line 5, referer: http:/XXXXX.YYY.ZZZ/ganglia/?...

Corresponding code snippet:

if (isset($_GET['date_only'])) {
$d = date("r");
echo $d;
exit(0);
}

@wookietreiber
Copy link

Same here, too. Please let us know in case you need any information about versions of involved components.

@docent-net
Copy link

I'm not sure if this is a bug. date.timezone should be set in php.ini - if it's not than this is a environment issue that should be resolved by server admin. According to http://www.php.net/manual/en/function.date-default-timezone-get.php:

"Prior to PHP 5.4.0 only: Querying the host operating system (if supported and allowed by the OS). This uses an algorithm that has to guess the timezone. This is by no means going to work correctly for every situation. A warning is shown when this stage is reached. Do not rely on it to be guessed correctly, and set date.timezone to the correct timezone instead."

One should use date_default_timezone_get() only when service is hosted on server when he doesn;t have root privileges to change php.ini or can't set date.timezone in .htaccess due to webserver privileges. Also it is used rather when we wan't to set another timezone for some reasons. In that case imo there should be some configuration directive setting this in conf_default.php.

What's your thoughts on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants