Jump to content

how to remove date error code


Notretsam

Recommended Posts

I keep getting the below error, I know its related to the date timezone and I need to add it to page.

 

However, for some reason adding date_default_timezone_set("Europe/London"); to page doesn't get rid of error

 

any ideas on what code I can use to get rid of this annoying error.

 

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.

 

 

Link to comment
Share on other sites

Calling date_default_timezone_set() will work as long as you provide a valid timezone and you called it before any date () calls.

I recommend putting it at the beginning of the file.

Link to comment
Share on other sites

yeah I put it at top of any file that uses date but still getting the error

 

far as I know there shouldn't be anything wrong with this but still shows the error seen in OP.

<?php
date_default_timezone_set("Europe/London");
/* then rest of page code below it */
?>

I should add that when there not a 2nd error on page, it doesn't show then, but always shows up along side a 2nd error, which is very weird.

Edited by Notretsam
Link to comment
Share on other sites

Check what is happening using

 

<?php
date_default_timezone_set('Europe/London');

if (date_default_timezone_get()) {
    echo 'date_default_timezone_set: ' . date_default_timezone_get() . '<br />';
}

if (ini_get('date.timezone')) {
    echo 'date.timezone: ' . ini_get('date.timezone');
}

?>
Taken from http://php.net/manual/en/function.date-default-timezone-get.php
Link to comment
Share on other sites

Ingolme

 

this is what I get using php error coding

 

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.

Link to comment
Share on other sites

That code doesn't show anything dsoneuk

 

All I see is below, line 116 is the sql bind line in code.

Warning: Unknown: 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. 
in admengine.php on line 116

/* this second error ignore, above only shows up when there's a 2nd error on page */ 
Parse error: syntax error, unexpected '$matchIDpone' (T_VARIABLE) in admengine.php on line 116
Edited by Notretsam
Link to comment
Share on other sites

Strange would have thought you would at least got 'UTC' timezone since that is what it selected? try adding else condition to test it is actually processing if condition

<?php
date_default_timezone_set('Europe/London');

if (date_default_timezone_get()) {
    echo 'date_default_timezone_set: ' . date_default_timezone_get() . '<br />';
}
else
{
echo 'Apparently No date_default_timezone_set <br/>';
}

if (ini_get('date.timezone')) {
    echo 'date.timezone: ' . ini_get('date.timezone');
}
else
{
echo 'Apparently No date.timezone set <br/>';
}
?>
Link to comment
Share on other sites

/* this second error ignore, above only shows up when there's a 2nd error on page */

That's a problem. Because if there is a parse error, then PHP will not execute any code at all, including any calls to try and change the timezone. So if you're only seeing that error message when the code does not get executed, then I bet you have the timezone misspelled or defined incorrectly in php.ini.
Link to comment
Share on other sites

That's a problem. Because if there is a parse error, then PHP will not execute any code at all, including any calls to try and change the timezone. So if you're only seeing that error message when the code does not get executed, then I bet you have the timezone misspelled or defined incorrectly in php.ini.

 

I deliberately did the error, so I can see the date error , I put plain text instead of a variable in sql query , so "Var" instead of "$Var"

 

The error is only out putted by PHP when there a 2nd error, you would think it always show up if it was an actual error, if that makes sense.

 

Maybe it is something in php.ini but I don't touch that file. so if it is misspelled, then that be hosting company then. Maybe I need to contact them.

Link to comment
Share on other sites

After thinking about it more there, am now thinking its what justanotherguy said (an Ingolme eluded to), the parse error isn't triggering any code, so the date error is a result off the second error.

 

If there was an actual error with the date timezone, then it would always show up as a single error I would think.

 

You's know how to wrap paragraph tags around each error reported on a page? below code is what I use but bit of a pain with the date error showing up.

ini_set('display_errors', 1);
error_reporting(E_ALL);
Edited by Notretsam
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...