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


PHP Time::add方法代码示例

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


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

示例1: indexToday

 /**
  * Index method
  *
  * @return void
  */
 public function indexToday($dayOffset = 0)
 {
     $dayStart = null;
     $dayEnd = null;
     $this->getDay($dayOffset, $dayStart, $dayEnd, "America/Chicago");
     $query = $this->Sessions->find()->where(['Sessions.created >=' => $dayStart])->where(['Sessions.created <=' => $dayEnd])->contain(['Users', 'Projects', 'Tasks'])->order(['Sessions.created' => 'DESC']);
     // this is just total elapsed time for the day not a real datetime
     $totalTime = new Time('2000-01-01');
     //debug($totalTime);
     $recs = $query->toArray();
     //debug($recs);die;
     $index = 0;
     foreach ($recs as $session) {
         $start = new Time($session['created']);
         $stop = new Time($session['stopped']);
         $interval = $start->diff($stop);
         $totalTime->add($interval);
         // if elapsed time is more than 0 days, show the day part too
         if ($interval->days > 0) {
             $timeLapse = $interval->format('%D:%H:%I');
         } else {
             $timeLapse = $interval->format('%H:%I');
         }
         // just show MM:SS
         /* show state */
         if ($session->state == 0) {
             $state = "not started";
         } else {
             if ($session->state == 1) {
                 $state = "<span style='font-weight: normal;'>STARTED</span>";
             } else {
                 if ($session->state == 2) {
                     $state = "stopped";
                 } else {
                     $state = "invalid";
                 }
             }
         }
         $recs[$index]['timeLapse'] = $timeLapse;
         $recs[$index]['totalTime'] = $totalTime->format('H:i');
         $recs[$index]['stateDesc'] = $state;
         $index++;
     }
     $this->set('sessions', $recs);
     $this->set('totalTime', $totalTime);
     //debug($sessions);die;
     $this->set('_serialize', ['sessions']);
 }
开发者ID:datalab1-com,项目名称:theme1,代码行数:53,代码来源:SessionsController.php


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