Hi
I’m using the below code to collect the timestamp of the time an image was uploaded using the BP-Album plugin, but need it to display in the same way that the activity stream displays time elapsed since i.e. “Posted 5 days, 17 hours ago”
picture->date_uploaded; ?>
Does anyone know how to convert it?
I did track down the below but I couldn’t work out how to add the images timestamp to it. Any help would be really appreciated
<?php
$time = strtotime('2010-04-28 17:25:43');
echo 'event happened '.humanTiming($time).' ago';
function humanTiming ($time)
{
$time = time() - $time; // to get the time since that moment
$tokens = array (
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach ($tokens as $unit => $text) {
if ($time < $unit) continue;
$numberOfUnits = floor($time / $unit);
return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'');
}
}
?>