otuatail Posted September 12, 2016 Share Posted September 12, 2016 Hi I have used this for some time now everywhere on a website. (Very old) 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 the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /vhost/vhost15/d/e/s/desmond-otoole.co.uk/www/Forum/LogMe.php on line 58 Is there a quick fix for this if it is outdated. Preferably for the UK and observing summertime. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/302160-datey-m-d-histime/ Share on other sites More sharing options...
Psycho Posted September 12, 2016 Share Posted September 12, 2016 Not sure exactly what you area asking. The warning message states what needs to be done: "You are *required* to use the date.timezone setting or the date_default_timezone_set() function". If you go to the manual page for the date() function you should be able to figure it out by looking at any of the examples. Although, it is just a warning. Your error reporting in a production site should ignore warnings anyway. But, it would be best to 'fix' the problem. Quote Link to comment https://forums.phpfreaks.com/topic/302160-datey-m-d-histime/#findComment-1537421 Share on other sites More sharing options...
taquitosensei Posted September 12, 2016 Share Posted September 12, 2016 It says right in the error message what to do. date_default_timezone_set("Your timezone here"); Mine is "America/Chicago". You'll have to look yours up. Quote Link to comment https://forums.phpfreaks.com/topic/302160-datey-m-d-histime/#findComment-1537422 Share on other sites More sharing options...
Barand Posted September 12, 2016 Share Posted September 12, 2016 You would use "Europe/London" The best place to set the default timezone is in your php.ini file. That will save you from having to change every program. Quote Link to comment https://forums.phpfreaks.com/topic/302160-datey-m-d-histime/#findComment-1537430 Share on other sites More sharing options...
otuatail Posted September 12, 2016 Author Share Posted September 12, 2016 I don't have access to php.ini I don't own the server it is on. Quote Link to comment https://forums.phpfreaks.com/topic/302160-datey-m-d-histime/#findComment-1537449 Share on other sites More sharing options...
Jacques1 Posted September 12, 2016 Share Posted September 12, 2016 Have you read any of the replies? The error message tells you exactly what you need to do. taquitosensei even posted the code. And Barand additionally told you the timezone you're in. What more do you need? A tutorial for using the keyboard? Quote Link to comment https://forums.phpfreaks.com/topic/302160-datey-m-d-histime/#findComment-1537450 Share on other sites More sharing options...
otuatail Posted September 15, 2016 Author Share Posted September 15, 2016 The problem I have is that I want the summer time now not GMT. time(); is giving me a value of GMT. Quote Link to comment https://forums.phpfreaks.com/topic/302160-datey-m-d-histime/#findComment-1537581 Share on other sites More sharing options...
otuatail Posted September 15, 2016 Author Share Posted September 15, 2016 (edited) What I am doing is $value = time(); This is returning a GMT value; date('I'); which isn't documented in the manual returns 0 date('e') returns +0000 Any suggestions? I have also been told that as I am on a shared server anyone can mess around with the INI file. This is mad. Edited September 15, 2016 by otuatail Quote Link to comment https://forums.phpfreaks.com/topic/302160-datey-m-d-histime/#findComment-1537582 Share on other sites More sharing options...
Barand Posted September 15, 2016 Share Posted September 15, 2016 date_default_timezone_set("Europe/London"); $now = new DateTime(); echo 'Time now: ' . $now->format('Y-m-d H:i:s') . '<br>'; //--> 2016-09-15 11:50:01 $now->setTimezone(new DateTimeZone('UTC')); echo 'Time UTC: ' . $now->format('Y-m-d H:i:s') . '<br>'; //--> 2016-09-15 10:50:01 Quote Link to comment https://forums.phpfreaks.com/topic/302160-datey-m-d-histime/#findComment-1537583 Share on other sites More sharing options...
otuatail Posted September 15, 2016 Author Share Posted September 15, 2016 date_default_timezone_set("Europe/London"); This works ahead of the time(); Looks like I have to do it because some other sod might change it. I used $now = new DateTime(); echo 'Time now: ' . $now->format('Y-m-d H:i:s') ; but got Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): 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 /vhost/vhost15/d/e/s/desmond-otoole.co.uk/www/banking/LogMe.php:64 Stack trace: #0 /vhost/vhost15/d/e/s/desmond-otoole.co.uk/www/banking/LogMe.php(64): DateTime->__construct() #1 {main} thrown in /vhost/vhost15/d/e/s/desmond-otoole.co.uk/www/banking/LogMe.php on line 64 Quote Link to comment https://forums.phpfreaks.com/topic/302160-datey-m-d-histime/#findComment-1537584 Share on other sites More sharing options...
Barand Posted September 15, 2016 Share Posted September 15, 2016 Did you forget the date_default_timezone_set("Europe/London"); ? Quote Link to comment https://forums.phpfreaks.com/topic/302160-datey-m-d-histime/#findComment-1537586 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.