/** * @param PcUser $loggedInUser * @param int $forcedTimeFormatId * @return string */ public function getHumanFriendlyTime(PcUser $loggedInUser, $forcedTimeFormatId = null) { if ($this->integerValue === NULL) { return ''; } list($hour, $minute) = $this->getDueTimeHourAndMinute(); $timeFormat = $forcedTimeFormatId !== null ? $forcedTimeFormatId : $loggedInUser->getTimeFormat(); if ($timeFormat == 1) { if (strlen($minute) == 1) { $minute = '0' . $minute; } return $hour . ':' . $minute; } else { // see http://en.wikipedia.org/wiki/24-hour_clock $pm = null; if ($hour > 12) { $hour -= 12; $pm = true; } else { if ($hour == 12) { $pm = true; } else { if ($hour == 0) { $hour = 12; } $pm = false; } } if (strlen($minute) == 1) { $minute = '0' . $minute; } return $hour . ':' . $minute . ($pm ? 'pm' : 'am'); } }