Notretsam Posted October 27, 2016 Share Posted October 27, 2016 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 More sharing options...
Ingolme Posted October 27, 2016 Share Posted October 27, 2016 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 More sharing options...
Notretsam Posted October 28, 2016 Author Share Posted October 28, 2016 (edited) 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 October 28, 2016 by Notretsam Link to comment Share on other sites More sharing options...
Ingolme Posted October 28, 2016 Share Posted October 28, 2016 What do the errors say? Link to comment Share on other sites More sharing options...
dsonesuk Posted October 28, 2016 Share Posted October 28, 2016 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 More sharing options...
Notretsam Posted October 30, 2016 Author Share Posted October 30, 2016 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 More sharing options...
Notretsam Posted October 30, 2016 Author Share Posted October 30, 2016 thanks dsoneuk , I give that a go and see what it says. Link to comment Share on other sites More sharing options...
Notretsam Posted October 30, 2016 Author Share Posted October 30, 2016 (edited) 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 October 30, 2016 by Notretsam Link to comment Share on other sites More sharing options...
dsonesuk Posted October 30, 2016 Share Posted October 30, 2016 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 More sharing options...
Ingolme Posted October 30, 2016 Share Posted October 30, 2016 You should fix that syntax error. It's very important. Show us the code between lines 114 and 118. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 31, 2016 Share Posted October 31, 2016 /* 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 More sharing options...
Notretsam Posted November 1, 2016 Author Share Posted November 1, 2016 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 More sharing options...
Ingolme Posted November 1, 2016 Share Posted November 1, 2016 When there is a syntax error in a file, none of the code in that file gets executed, including the timezone code. Link to comment Share on other sites More sharing options...
Notretsam Posted November 1, 2016 Author Share Posted November 1, 2016 (edited) 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 November 1, 2016 by Notretsam Link to comment Share on other sites More sharing options...
justsomeguy Posted November 1, 2016 Share Posted November 1, 2016 There are settings for error_prepend_string and error_append_string that you can use. http://php.net/manual/en/errorfunc.configuration.php Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now