本文整理匯總了PHP中DateTimeUtil::convertDbFormatDateTimeToTimeStamp方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateTimeUtil::convertDbFormatDateTimeToTimeStamp方法的具體用法?PHP DateTimeUtil::convertDbFormatDateTimeToTimeStamp怎麽用?PHP DateTimeUtil::convertDbFormatDateTimeToTimeStamp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DateTimeUtil
的用法示例。
在下文中一共展示了DateTimeUtil::convertDbFormatDateTimeToTimeStamp方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getTimeSinceDisplayContent
/**
* 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;
}
示例2: getTimeSinceDisplayContent
/**
* 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']);
}
}
}
}