News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Forum will not load - StrfTime error on Subs.php

Started by sdietz, July 07, 2011, 11:51:31 AM

Previous topic - Next topic

sdietz

Hi Everyone,

Last night we starting getting an error when you go to the forums homepage. The forum does not load it just stats this error:

2: strftime(): 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/New_York' for '-4.0/DST' instead
File: \webroot\forum\Sources\Subs.php
Line: 877


I've checked the php.ini file and the date.timezone (we are located in New York (USA) settings is set as:

date.timezone = 'America/New_York'

Here is also what is on line 875 - 879 of the Subs.php file:

foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label)
         if (strpos($str, $token) !== false)
            $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str);
      if (strpos($str, '%p'))
         $str = str_replace('%p', (strftime('%H', $time) < 12 ? 'am' : 'pm'), $str);


I am not a programmer by any means so not sure if the above settings are correct.

Thanks!

MrPhil

#1
Well, yesterday your host upgraded to PHP 5.3, which complains when it thinks there is no timezone defined before you use a date/time function. You say that you have a php.ini with the right setting, but apparently it's not being processed.

  • Check the permissions on php.ini -- it should be readable but not globally writable (644 is best, never 666 or 777). Many hosts will ignore (disable access to) any file or directory that can be written to by anyone.
  • Is php.ini in the root directory of SMF (same directory as Settings.php), or higher (in a parent directory) but not above the site's HTML root (http://www.yoursite.com/)? If it's up too high, or not in the directory path to SMF, it won't be seen.
  • Are you getting a 500 (Internal Server) error due to an error in php.ini? You might want to comment out (with ; ) any other lines in that file, to see if they're messing it up.
  • Do you have any code in .htaccess to protect php.ini against being read by hackers? If so, maybe it's incorrect and you're also not allowing your own server to read it!
You can run the following script:
<?php phpinfo(); ?>
before and after any change to php.ini, to see if the changes are taking effect. You can also look at the timezone setting (date > Default timezone) to see if it is set and correct.

If none of this stops the messages, talk with your host.

You may be able to modify the "default timezone" entry in the database, if it exists, possibly through the administration panel, or if not, through phpMyAdmin. In the smf_settings table, look for "default_timezone". If it's something like /etc/GMT+5, or is missing, change/add the correct value of America/New_York. With that, you might not even need the php.ini file entry.

Advertisement: