Example #1
0
 /**
  * Given a datetime, return a string representation of how much time has elapsed since the $dateTime to now
  * @param $dateTime
  * @return string
  */
 public static function getTimeSinceDisplayContent($dateTime)
 {
     $nowTimeStamp = time();
     $dateTimeStamp = DateTimeUtil::convertDbFormatDateTimeToTimeStamp($dateTime);
     $timeSinceLatestUpdate = $nowTimeStamp - $dateTimeStamp;
     $timeForString = array('days' => floor($timeSinceLatestUpdate / 86400), 'hours' => floor($timeSinceLatestUpdate / 3600));
     if ($timeForString['days'] == 0) {
         if ($timeForString['hours'] == 1) {
             $string = Zurmo::t('MashableInboxModule', '{hours} hour ago', array('{hours}' => $timeForString['hours']));
         } else {
             $string = Zurmo::t('MashableInboxModule', '{hours} hours ago', array('{hours}' => $timeForString['hours']));
         }
     } elseif ($timeForString['days'] == 1) {
         $string = Zurmo::t('MashableInboxModule', '{days} day ago', array('{days}' => $timeForString['days']));
     } else {
         $string = Zurmo::t('MashableInboxModule', '{days} days ago', array('{days}' => $timeForString['days']));
     }
     return $string;
 }
 /**
  * Given a datetime, return a string representation of how much time has elapsed since the $dateTime to now
  * @param $dateTime
  * @return string
  */
 public static function getTimeSinceDisplayContent($dateTime)
 {
     assert('DateTimeUtil::isValidDbFormattedDateTime($dateTime)');
     $nowTimeStamp = time();
     $dateTimeStamp = DateTimeUtil::convertDbFormatDateTimeToTimeStamp($dateTime);
     $timeSinceLatestUpdate = $nowTimeStamp - $dateTimeStamp;
     $timeForString = array('days' => floor($timeSinceLatestUpdate / 86400), 'hours' => floor($timeSinceLatestUpdate / 3600), 'minutes' => floor($timeSinceLatestUpdate / 60), 'seconds' => floor($timeSinceLatestUpdate));
     if ($timeForString['days'] >= 1) {
         return Zurmo::t('Core', '{n} day ago|{n} days ago', $timeForString['days']);
     } else {
         if ($timeForString['hours'] >= 1) {
             return Zurmo::t('Core', '{n} hour ago|{n} hours ago', $timeForString['hours']);
         } else {
             if ($timeForString['minutes'] >= 1) {
                 return Zurmo::t('Core', '{n} minute ago|{n} minutes ago', $timeForString['minutes']);
             } else {
                 return Zurmo::t('Core', '{n} second ago|{n} seconds ago', $timeForString['seconds']);
             }
         }
     }
 }