I'm getting this error on my nginx hosted server:
Fatal error: TimeElapsedString(): Unknown property (w) in /var/www/script/system/framework.engine.php on line 51
TimeElapsedString:
function TimeElapsedString($datetime, $full = false)
{
date_default_timezone_set('UTC');
$now = new DateTime;
$ago = new DateTime($datetime);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7); // LINE 51
$diff->d -= $diff->w * 7;
$string = array
(
'y' => 'year',
'm' => 'month',
'w' => 'week',
'd' => 'day',
'h' => 'hour',
'i' => 'minute',
's' => 'second',
);
foreach ($string as $k => &$v)
{
if ($diff->$k)
{
$v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');
}
else
{
unset($string[$k]);
}
}
if (!$full) $string = array_slice($string, 0, 1);
return $string ? implode(', ', $string) . ' ago' : 'just now';
}
Everything just working perfect on the localhost (wamp) the php version in the hosted server is 5.3.3 so I ca'nt really see that problem. also I used this function in another nginx server and its also working without any problem.
the function is from this answer : Converting timestamp to time ago in PHP e.g 1 day ago, 2 days ago...