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


PHP DateTimeHelper::create方法代码示例

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


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

示例1: getTimeTotals

 public function getTimeTotals($user_id, $time_range)
 {
     switch ($time_range) {
         case 'overall':
             $date_from = null;
             $date_to = null;
             break;
         case 'this_week':
             $days = DateTimeHelper::create()->getDaysOfWeek(date('W'), date('Y'));
             $date_from = date('Y-m-d 00:00:00', $days[1]);
             $date_to = date('Y-m-d 23:59:59', $days[7]);
             break;
         case 'last_week':
             $days = DateTimeHelper::create()->getDaysOfWeek(date('W') - 1, date('Y'));
             $date_from = date('Y-m-d 00:00:00', $days[1]);
             $date_to = date('Y-m-d 23:59:59', $days[7]);
             break;
         case 'this_month':
             $date_from = date('Y-m-d 00:00:00', mktime(00, 00, 00, date('m'), 01));
             $date_to = date('Y-m-d 23:59:59', strtotime($date_from . '+1 MONTH -1 SECOND'));
             break;
         case 'last_month':
             $month = strtotime('last month');
             $date_from = date('Y-m-d 00:00:00', mktime(00, 00, 00, date('m', $month), 01));
             $date_to = date('Y-m-d 23:59:59', strtotime($date_from . '+1 MONTH -1 SECOND'));
             break;
     }
     $query = Doctrine_Query::create()->select('p.*, i.*, SUM(i.value) as total')->from('Project p')->where('i.user_id=?', $user_id)->innerJoin('p.TimeLogItems i')->groupBy('p.id')->orderBy('p.name');
     if ($date_from != null && $date_to != null) {
         $query->andWhere('i.itemdate >= ? AND i.itemdate <= ?', array($date_from, $date_to));
     }
     return $query->execute();
 }
开发者ID:newZinc,项目名称:timehive,代码行数:33,代码来源:ProjectTable.class.php

示例2: executeIndex

 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->week = $request->getParameter('week', date('W'));
     $this->year = $request->getParameter('year', date('Y'));
     $days = DateTimeHelper::create()->getDaysOfWeek($this->week, $this->year);
     $this->weekstart = $days[1];
     $account_id = $this->getUser()->getAttribute('account_id');
     $this->projects = ProjectTable::getInstance()->findByAccountId($account_id);
     $this->user = UserTable::getInstance()->find($this->getUser()->getAttribute('uid'));
     $this->item_types = TimeItemTypeTable::getInstance()->findByAccountId($account_id);
     $this->default_item_type = TimeItemTypeTable::getInstance()->findDefaultForAccount($account_id);
     if ($this->default_item_type) {
         $this->default_item_type_name = $this->default_item_type->getName();
     } else {
         $this->default_item_type_name = null;
     }
     $items = Doctrine_Query::create()->from('TimeLogItem ti')->where('ti.itemdate >= ? and itemdate <= ? and ti.user_id = ?', array(date('Y-m-d', $days[1]), date('Y-m-d', $days[1] + 5 * 24 * 60 * 60), $this->getUser()->getAttribute('uid')))->execute();
     $this->time_items = new TimeItemSelector($items);
     $this->account = AccountTable::getInstance()->find($account_id);
 }
开发者ID:newZinc,项目名称:timehive,代码行数:25,代码来源:actions.class.php


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