当前位置: 首页>>代码示例>>PHP>>正文


PHP CTimeHelper::timeDifference方法代码示例

本文整理汇总了PHP中CTimeHelper::timeDifference方法的典型用法代码示例。如果您正苦于以下问题:PHP CTimeHelper::timeDifference方法的具体用法?PHP CTimeHelper::timeDifference怎么用?PHP CTimeHelper::timeDifference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CTimeHelper的用法示例。


在下文中一共展示了CTimeHelper::timeDifference方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: timeLapse

 /**
  *
  * @param JDate $date
  *
  */
 public static function timeLapse($date)
 {
     $now = new JDate();
     $dateDiff = CTimeHelper::timeDifference($date->toUnix(), $now->toUnix());
     if ($dateDiff['days'] > 0) {
         $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['days']) ? 'CC LAPSED DAY MANY' : 'CC LAPSED DAY', $dateDiff['days']);
     } elseif ($dateDiff['hours'] > 0) {
         $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['hours']) ? 'CC LAPSED HOUR MANY' : 'CC LAPSED HOUR', $dateDiff['hours']);
     } elseif ($dateDiff['minutes'] > 0) {
         $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['minutes']) ? 'CC LAPSED MINUTE MANY' : 'CC LAPSED MINUTE', $dateDiff['minutes']);
     } else {
         $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['seconds']) ? 'CC LAPSED SECOND MANY' : 'CC LAPSED SECOND', $dateDiff['seconds']);
     }
     return $lapse;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:20,代码来源:time.php

示例2: timeLapse

 /**
  *
  * @param JDate $date
  *
  */
 public static function timeLapse($date)
 {
     $now = new JDate();
     $dateDiff = CTimeHelper::timeDifference($date->toUnix(), $now->toUnix());
     if ($dateDiff['days'] > 0) {
         $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['days']) ? 'COM_COMMUNITY_LAPSED_DAY_MANY' : 'COM_COMMUNITY_LAPSED_DAY', $dateDiff['days']);
     } elseif ($dateDiff['hours'] > 0) {
         $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['hours']) ? 'COM_COMMUNITY_LAPSED_HOUR_MANY' : 'COM_COMMUNITY_LAPSED_HOUR', $dateDiff['hours']);
     } elseif ($dateDiff['minutes'] > 0) {
         $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['minutes']) ? 'COM_COMMUNITY_LAPSED_MINUTE_MANY' : 'COM_COMMUNITY_LAPSED_MINUTE', $dateDiff['minutes']);
     } else {
         if ($dateDiff['seconds'] == 0) {
             $lapse = JText::_("COM_COMMUNITY_ACTIVITIES_MOMENT_AGO");
         } else {
             $lapse = JText::sprintf(CStringHelper::isPlural($dateDiff['seconds']) ? 'COM_COMMUNITY_LAPSED_SECOND_MANY' : 'COM_COMMUNITY_LAPSED_SECOND', $dateDiff['seconds']);
         }
     }
     return $lapse;
 }
开发者ID:Simarpreet05,项目名称:joomla,代码行数:24,代码来源:time.php

示例3: timeLapse

 /**
  *
  * @param JDate $date
  *
  */
 public static function timeLapse($date, $showFull = true)
 {
     $now = JFactory::getDate();
     $html = '';
     $diff = CTimeHelper::timeDifference($date->toUnix(), $now->toUnix());
     if (!empty($diff['days'])) {
         $days = $diff['days'];
         $months = ceil($days / 30);
         switch ($days) {
             case $days == 1:
                 // @rule: Something that happened yesterday
                 $html .= JText::_('COM_COMMUNITY_LAPSED_YESTERDAY');
                 break;
             case $days > 1 && $days <= 7 && $days < 30:
                 // @rule: Something that happened within the past 7 days
                 $html .= JText::sprintf('COM_COMMUNITY_LAPSED_DAYS', $days) . ' ';
                 break;
             case $days > 1 && $days > 7 && $days < 30:
                 // @rule: Something that happened within the month but after a week
                 $weeks = round($days / 7);
                 $html .= JText::sprintf(CStringHelper::isPlural($weeks) ? 'COM_COMMUNITY_LAPSED_WEEK_MANY' : 'COM_COMMUNITY_LAPSED_WEEK', $weeks) . ' ';
                 break;
             case $days >= 30 && $days < 365:
                 // @rule: Something that happened months ago
                 $months = round($days / 30);
                 $html .= JText::sprintf(CStringHelper::isPlural($months) ? 'COM_COMMUNITY_LAPSED_MONTH_MANY' : 'COM_COMMUNITY_LAPSED_MONTH', $months) . ' ';
                 break;
             case $days > 365:
                 // @rule: Something that happened years ago
                 $years = round($days / 365);
                 $html .= JText::sprintf(CStringHelper::isPlural($years) ? 'COM_COMMUNITY_LAPSED_YEAR_MANY' : 'COM_COMMUNITY_LAPSED_YEAR', $years) . ' ';
                 break;
         }
     } else {
         // We only show he hours if it is less than 1 day
         if (!empty($diff['hours'])) {
             if (!empty($diff['minutes'])) {
                 if ($diff['hours'] == 1) {
                     $html .= JText::sprintf('COM_COMMUNITY_LAPSED_HOUR', $diff['hours']) . ' ';
                 } else {
                     $html .= JText::sprintf('COM_COMMUNITY_LAPSED_HOURS', $diff['hours']) . ' ';
                 }
             } else {
                 $html .= JText::sprintf('COM_COMMUNITY_LAPSED_HOURS_AGO', $diff['hours']) . ' ';
             }
         }
         if ($showFull && !empty($diff['hours']) || empty($diff['hours'])) {
             if (!empty($diff['minutes'])) {
                 if ($diff['minutes'] == 1) {
                     $html .= JText::sprintf('COM_COMMUNITY_LAPSED_MINUTE', $diff['minutes']) . ' ';
                 } else {
                     $html .= JText::sprintf('COM_COMMUNITY_LAPSED_MINUTES', $diff['minutes']) . ' ';
                 }
             }
         }
     }
     if (empty($html)) {
         $html .= JText::_('COM_COMMUNITY_LAPSED_LESS_THAN_A_MINUTE');
     }
     return $html;
 }
开发者ID:Jougito,项目名称:DynWeb,代码行数:66,代码来源:time.php

示例4: _createdLapse

 /**
  * Return html formatted lapse time
  * @param	JDate date The date you want to compare	 	
  * @access 	private	 
  */
 function _createdLapse(&$date)
 {
     CFactory::load('helpers', 'time');
     $now =& JFactory::getDate();
     $html = '';
     $diff = CTimeHelper::timeDifference($date->toUnix(), $now->toUnix());
     if (!empty($diff['days'])) {
         $days = $diff['days'];
         $months = ceil($days / 30);
         if ($days == 1) {
         }
         switch ($days) {
             case $days == 1:
                 // @rule: Something that happened yesterday
                 $html .= JText::_('CC LAPSED YESTERDAY');
                 break;
             case $days > 1 && $days < 7 && $days < 30:
                 // @rule: Something that happened within the past 7 days
                 $html .= JText::sprintf('CC LAPSED DAYS', $days) . ' ';
                 break;
             case $days > 1 && $days > 7 && $days < 30:
                 // @rule: Something that happened within the month but after a week
                 $weeks = round($days / 7);
                 $html .= JText::sprintf(CStringHelper::isPlural($weeks) ? 'CC LAPSED WEEK MANY' : 'CC LAPSED WEEK', $weeks) . ' ';
                 break;
             case $days > 30 && $days < 365:
                 // @rule: Something that happened months ago
                 $months = round($days / 30);
                 $html .= JText::sprintf(CStringHelper::isPlural($months) ? 'CC LAPSED MONTH MANY' : 'CC LAPSED MONTH', $months) . ' ';
                 break;
             case $days > 365:
                 // @rule: Something that happened years ago
                 $years = round($days / 365);
                 $html .= JText::sprintf(CStringHelper::isPlural($years) ? 'CC LAPSED YEAR MANY' : 'CC LAPSED YEAR', $years) . ' ';
                 break;
         }
     } else {
         // We only show he hours if it is less than 1 day
         if (!empty($diff['hours'])) {
             $html .= JText::sprintf('CC LAPSED HOURS', $diff['hours']) . ' ';
         }
         if (!empty($diff['minutes'])) {
             $html .= JText::sprintf('CC LAPSED MINUTES', $diff['minutes']) . ' ';
         }
     }
     if (empty($html)) {
         $html .= JText::_('CC LAPSED LESS THAN A MINUTE');
     }
     if ($html != JText::_('CC LAPSED YESTERDAY')) {
         $html .= JText::_('CC LAPSED AGO');
     }
     return $html;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:58,代码来源:activities.php


注:本文中的CTimeHelper::timeDifference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。