I'm trying to create a view helper that will display the number of minutes, hours, or days that have passed since...right now. I'm not really sure how to do it. It looks like the date comparison is working, but I don't know how to get the number. Here's what I have so far:
<?php
class Zend_View_Helper_RecentDate
{
public function recentDate($datetime)
{
$date = new Zend_Date($datetime);
switch ($date) {
case($date->isEarlier(1, Zend_Date::HOUR)):
$message = 'was minutes ago';
break;
case($date->isEarlier(24, Zend_Date::HOUR)):
$message = 'was hours ago';
break;
case($date->isEarlier(48, Zend_Date::HOUR)):
$message = 'Yesterday';
break;
default:
$message = 'was days ago';
break;
}
return $message;
}
}
I want to replace "was" with the actual number of minutes/hours/days passed.