本文整理汇总了PHP中DateTimeUtil::getTimeSinceDisplayContent方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeUtil::getTimeSinceDisplayContent方法的具体用法?PHP DateTimeUtil::getTimeSinceDisplayContent怎么用?PHP DateTimeUtil::getTimeSinceDisplayContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeUtil
的用法示例。
在下文中一共展示了DateTimeUtil::getTimeSinceDisplayContent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderSubjectAndLatestForDisplayView
/**
* Renders string content for the conversation subject and either the description or latest conversation comment
* if it exists.
* @param Conversation $conversation
* @return string
*/
public static function renderSubjectAndLatestForDisplayView(Conversation $conversation)
{
$url = Yii::app()->createUrl('/conversations/default/details', array('id' => $conversation->id));
$content = $conversation->subject;
$details = ZurmoHtml::tag('span', array('class' => 'list-item-details'), DateTimeUtil::getTimeSinceDisplayContent($conversation->latestDateTime));
$link = ZurmoHtml::link($content, $url);
return $link . $details;
}
示例2: getFeedInformationForDashboard
/**
* Get feed information if projects for user
* @param ProjectAuditEvent $projectAuditEvent
* @return string
*/
public static function getFeedInformationForDashboard(ProjectAuditEvent $projectAuditEvent)
{
assert('$projectAuditEvent instanceof ProjectAuditEvent');
$project = Project::getById(intval($projectAuditEvent->project->id));
$dateTime = DateTimeUtil::getTimeSinceDisplayContent($projectAuditEvent->dateTime);
$data = array('{timeSpanLabel}' => $dateTime);
if (ActionSecurityUtil::canCurrentUserPerformAction('Details', $project)) {
$projectName = static::resolveProjectName($project);
$data['{projectname}'] = $projectName;
$user = User::getById($projectAuditEvent->user->id);
$data['{username}'] = $user->getFullName();
$unserializedData = unserialize($projectAuditEvent->serializedData);
if (is_array($unserializedData)) {
$data = array_merge($unserializedData, $data);
}
} else {
return Zurmo::t('ProjectsModule', '<strong>Activity on a restricted project
</strong> <small>about {timeSpanLabel}</small>', $data);
}
return static::getMessageContentByEventAndData($projectAuditEvent->eventName, $data);
}
示例3: testTimeDifference
public function testTimeDifference()
{
$time = date("Y-m-d H:i:s", strtotime('-5 hours', time()));
$timeDiff = DateTimeUtil::getTimeSinceDisplayContent($time);
$this->assertEquals('5 hours ago', $timeDiff);
$time = date("Y-m-d H:i:s", strtotime('-5 days', time()));
$timeDiff = DateTimeUtil::getTimeSinceDisplayContent($time);
$this->assertEquals('5 days ago', $timeDiff);
$time = date("Y-m-d H:i:s", strtotime('-5 minutes', time()));
$timeDiff = DateTimeUtil::getTimeSinceDisplayContent($time);
$this->assertEquals('5 minutes ago', $timeDiff);
$time = date("Y-m-d H:i:s", strtotime('-5 seconds', time()));
$timeDiff = DateTimeUtil::getTimeSinceDisplayContent($time);
$this->assertEquals('5 seconds ago', $timeDiff);
}
示例4: renderListViewContent
/**
* @param Notification $notification
* @return string
*/
public static function renderListViewContent(Notification $notification)
{
$content = strval($notification);
if ($content != null) {
$content = '<b>' . $content . '</b>';
}
if ($notification->notificationMessage->id > 0) {
if ($notification->notificationMessage->htmlContent != null) {
$content .= ZurmoHtml::wrapLabel(Yii::app()->format->raw($notification->notificationMessage->htmlContent), "last-comment");
} elseif ($notification->notificationMessage->textContent != null) {
$content .= ZurmoHtml::wrapLabel(Yii::app()->format->text($notification->notificationMessage->textContent), "last-comment");
}
}
$content .= ZurmoHtml::tag('span', array('class' => 'list-item-details'), DateTimeUtil::getTimeSinceDisplayContent($notification->createdDateTime));
return $content;
}
示例5: testGetTimeSinceDisplayContent
public function testGetTimeSinceDisplayContent()
{
//30 minutes ago
$timeStampLatestUpdate = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 30 * 60);
$timeSinceLastestUpdate = DateTimeUtil::getTimeSinceDisplayContent($timeStampLatestUpdate);
$this->assertEquals($timeSinceLastestUpdate, '0 hours ago');
//58 minutes ago
$timeStampLatestUpdate = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 58 * 60);
$timeSinceLastestUpdate = DateTimeUtil::getTimeSinceDisplayContent($timeStampLatestUpdate);
$this->assertEquals($timeSinceLastestUpdate, '0 hours ago');
//61 minutes ago
$timeStampLatestUpdate = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 61 * 60);
$timeSinceLastestUpdate = DateTimeUtil::getTimeSinceDisplayContent($timeStampLatestUpdate);
$this->assertEquals($timeSinceLastestUpdate, '1 hour ago');
//3 hours ago
$timeStampLatestUpdate = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 3 * 60 * 60);
$timeSinceLastestUpdate = DateTimeUtil::getTimeSinceDisplayContent($timeStampLatestUpdate);
$this->assertEquals($timeSinceLastestUpdate, '3 hours ago');
//27 hours ago
$timeStampLatestUpdate = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 27 * 60 * 60);
$timeSinceLastestUpdate = DateTimeUtil::getTimeSinceDisplayContent($timeStampLatestUpdate);
$this->assertEquals($timeSinceLastestUpdate, '1 day ago');
//10 days ago
$timeStampLatestUpdate = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 10 * 24 * 60 * 60);
$timeSinceLastestUpdate = DateTimeUtil::getTimeSinceDisplayContent($timeStampLatestUpdate);
$this->assertEquals($timeSinceLastestUpdate, '10 days ago');
}
示例6: getModelCreationTimeContent
public function getModelCreationTimeContent(RedBeanModel $model)
{
return DateTimeUtil::getTimeSinceDisplayContent($model->createdDateTime);
}