本文整理匯總了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();
}
示例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);
}