Page 1 of 1

Can you use date() ??

Posted: Thu Jun 20, 2013 3:50 am
by simonmlewis
Is there anything wrong in using this:

Code: Select all

$todaydate = date('Y-m-d');
I am getting a vast amount of errors saying:
[Wed Jun 19 07:16:40 2013] [warn] [client 90.209.131.62] mod_fcgid: stderr: 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 'Europe/London' for 'BST/1.0/DST' instead in /var/www/vhosts/site.co.uk/httpdocs/includes/categ.inc
Is it as simple as putting this at the top of the template file?

Code: Select all

date_default_timezone_set('GMT');

Re: Can you use date() ??

Posted: Thu Jun 20, 2013 4:03 am
by pbs
you can set date timezone in php.ini file

Re: Can you use date() ??

Posted: Thu Jun 20, 2013 4:07 am
by simonmlewis
date.timezone = Europe/London
Do I just add this line of code?

Re: Can you use date() ??

Posted: Thu Jun 20, 2013 4:29 am
by pbs
yeah, you can set time zone according to your requirement, please check this url

http://php.net/manual/en/timezones.php

Re: Can you use date() ??

Posted: Thu Jun 20, 2013 4:35 am
by simonmlewis
Cool - added it as described to PHP.ini. Will see tomorrow if the (over 1million) lines of errors have reduced by this. As a shed of them were down to times.

Re: Can you use date() ??

Posted: Thu Jun 20, 2013 5:11 pm
by pickle
It might be best to set the timezone to UTC, then translate to Europe/London time (which I think is GMT anyway). This will allow your code to work regardless of where the server is located, and will simplify any timezone translation you may need to do for users that aren't in the GMT timezone.