Date/Time error warning

I recently had a site hacked. After getting it back up and running I started to receive this message when testing the “Contact” page. This is an older site which was built for me and I know nothing about .php but am able to open the below referenced pages and can add/change code if anyone can make suggestions. First is the warning message and below that is the code on the lines (+) refereed to in those warnings. Sorry, not able to post a link due to forum rules.

Thanks for any help!

Warning: date() [function.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 ‘America/Los_Angeles’ for ‘PDT/-7.0/DST’ instead in /home/westli6/public_html/class.phpmailer.php on line 1925

Warning: date() [function.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 ‘America/Los_Angeles’ for ‘PDT/-7.0/DST’ instead in /home/westli6/public_html/class.phpmailer.php on line 1929 Could not instantiate mail function.

////////////////////////////////////

public static function RFCDate() {
$tz = date(‘Z’);
$tzs = ($tz < 0) ? ‘-’ : ‘+’;
$tz = abs($tz);
$tz = (int)($tz/3600)*100 + ($tz%3600)/60;
$result = sprintf("%s %s%04d", date(‘D, j M Y H:i:s’), $tzs, $tz);

return $result;

}

It says what you need to do, either update php.ini (and reload the web server) - or add your wanted timezone using ini_set

Thanks for the quick reply Jim

Sorry but this is all over my head. Copy & paste I can handle and re-uploading the file, not a problem. This hack has made a mess of things but not sure at this point if this was part of that.

Well, you can either set it in your php.ini file to be permanent throughout your site, or you can add one line at the
top of each page loosely like this:

date_default_timezone_set(‘America/Los_Angeles’);

You need to set the parm to point at your area. Not all cities have their own time zone. For instance, in my area
in New England, US, I use Boston or New York for my time zone. There is a list on PHP.net if you need it.

Thank you ErnieAlex. Sorry for being un-educated on all of this!

Sounds like the simplest way as you describe it would be to change the php.ini file. So, can you perhaps give me the correct line/s of code to insert into that file or would it be the same as the code you supplied for “each page”? Also, what line would I insert it into?

If that’s the case and I’m in Utah I assume I would substitute in:

date_default_timezone_set(‘America/Denver’) ?

There should be a date.timezone line in your php.ini, it might be commented out though (line starting with a semicolon)

This is the correct format

[php]date.timezone = “America/Denver”[/php]

Note that if you want to make a script that work for different time zones (ie users around the world) you usually want to use UTC in the application.

[hr]

The location of your php.ini file depends on your server config. You should be able to find it using

[php]<?php

phpinfo();[/php]

[hr]

After updating the ini file you will have to reload Apache.

[hr]

If you’re on shared hosting your easiest way to solve this is to just ask the customer support there

Normally they allow you to override php.ini, either with your own file or using a .htaccess file.

ie something like

[php]php_value date.timezone ‘Region/Zone’[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service