Doc Posted January 30, 2013 Share Posted January 30, 2013 After my web hosting company (1and1.com) switched from PHP 4 to 5, a script that once returned the current year A-OK no longer works; it now generates this error message that is e-mailed to me every time a page bearing this include is accessed: An error occurred in script'----------/includes/footer.php' on line 4:<br />date_default_timezone_get() [<ahref='function.date-default-timezone-get'>function.date-default-timezone-get</a>]:It is not safe to rely on the system's timezone settings. Please use thedate.timezone setting, the TZ environment variable or thedate_default_timezone_set() function. In case you used any of those methods andyou are still getting this warning, you most likely misspelled the timezoneidentifier. We selected 'America/New_York' for 'EST/-5.0/no DST'instead<br />Date/Time: 1-30-2013 07:51:12<br/><pre>Array .... Here is the code, including some changes I thought should correct the error or at least suppress the error messages: <?php if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")) @date_default_timezone_set(@date_default_timezone_get()); // date_default_timezone_set('America/New_York'); $startyear = 2009; $currentyear = date("Y"); if ($startyear == $currentyear) { echo 'Copyright © 2009'; } else { echo 'Copyright © 2009 - ' . $currentyear; } ?> How can I fix this error? Link to comment Share on other sites More sharing options...
Larry Posted January 30, 2013 Share Posted January 30, 2013 Use the line that's commented out and remove the one before it. Think about this logically: if you're getting the error message because the default time zone is not set, then calling date_default_timezone_get() won't do anything, right? Also, use curly brackets! 1 Link to comment Share on other sites More sharing options...
Doc Posted January 31, 2013 Author Share Posted January 31, 2013 Thanks, Larry, that solved the problem. I'd previously implemented the exact changes you suggested, using date_default_timezone_set('America/New_York'); and nothing above it, but it originally did not work for well over a month. In retrospect, I suspect the problem resulted from the 1and1.com server -- one of MANY they have -- but they evidently fixed it. I told them of the error but they initially dismissed my report, which is characteristic of them. BTW, if you ever start a web hosting company, I'd be your first customer and gladly pay several times what I'm paying 1and1. There must be many people like me who are frustrated with the ineptness and poor support of the major web hosting companies. Link to comment Share on other sites More sharing options...
Antonio Conte Posted January 31, 2013 Share Posted January 31, 2013 Do a few google searches. I'm sure you'll find good hosting located in your general area. Link to comment Share on other sites More sharing options...
Larry Posted February 1, 2013 Share Posted February 1, 2013 Thanks for the nice words, Doc, although don't hold your breath for me to start doing hosting! 1 and 1, from everything I've heard, is terrible, and should be avoided. Link to comment Share on other sites More sharing options...
Recommended Posts