Reply To: FireStats – Top 40 php script (now with added charts)

#14803
sonichouse
Participant

@Iris wrote:

Steve,

I get this error on the Summary Page.

Fatal error: Class 'DateTimeZone' not found in /shares/mss-hdd/Public/Our Sites/stats/functions.php on line 653

I tried with my timezone (“America/Regina”) and also one of the defaults you had listed. I only edited the one line in Functions.php – was there another place I was supposed to change?

Glad to see you incorporated the time out setting – saves me having to add it in future releases.

I would of preferred setting the value in php.ini but the MSS seems to be more finnicky then the slug your using. It’s not supported as much as the slug and that sometimes causes more debugging. I did set the value in php.ini but that didn’t work so your solution of setting the timezone within the php code is my only option for now.

Iris

Hi Iris,

Ok can you replace your DateFromUTC function as

function DateFromUTC($value)
{
if(!isDate($value))
return $value;

$dateTimeZoneUTC = timezone_open("UTC");
$dateTimeZone = timezone_open(date_default_timezone_get());

$dateTimeUTC = date_create("now", $dateTimeZoneUTC);
$dateTime = date_create("now", $dateTimeZone);

$timeOffset = $dateTimeZone->getOffset($dateTimeUTC) . " seconds";
$d=Date("Y-m-d H:i:s",strtotime($value));

$dateTime = date_create($d);
$dateTime->modify($timeOffset);

return $dateTime->format("Y-m-d H:i:s");
}

the function calls require php 5.1 or greater, which version are you running ?.

You only need to set the timezone in the line that is commented out on line ~115.

Did you restart the web server/php after setting the value in php.ini ?

/Steve

[EDIT] Updated source to 1.24 with above changes [/EDIT]