Jump to content

date("Y-m-d H:i:s",time())


otuatail

Recommended Posts

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!
 
 
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by otuatail
Link to comment
Share on other sites

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
 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.