當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateTimeUtil::convertDbFormatDateTimeToTimeStamp方法代碼示例

本文整理匯總了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;
 }
開發者ID:youprofit,項目名稱:Zurmo,代碼行數:24,代碼來源:DateTimeUtil.php

示例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']);
             }
         }
     }
 }
開發者ID:RamaKavanan,項目名稱:InitialVersion,代碼行數:26,代碼來源:DateTimeUtil.php


注:本文中的DateTimeUtil::convertDbFormatDateTimeToTimeStamp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。