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


PHP date::getLastMonth方法代码示例

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


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

示例1: computeBeginAndEnd

 /**
  * Compute the begin date and end date of a period.
  * 
  * @param  string    $period   all|today|yesterday|twodaysago|latest2days|thisweek|lastweek|thismonth|lastmonth
  * @access public
  * @return array
  */
 public function computeBeginAndEnd($period)
 {
     $this->app->loadClass('date');
     $today = date::today();
     $tomorrow = date::tomorrow();
     $yesterday = date::yesterday();
     $twoDaysAgo = date::twoDaysAgo();
     $period = strtolower($period);
     if ($period == 'all') {
         return array('begin' => '1970-1-1', 'end' => '2109-1-1');
     }
     if ($period == 'today') {
         return array('begin' => $today, 'end' => $tomorrow);
     }
     if ($period == 'yesterday') {
         return array('begin' => $yesterday, 'end' => $today);
     }
     if ($period == 'twodaysago') {
         return array('begin' => $twoDaysAgo, 'end' => $yesterday);
     }
     if ($period == 'latest3days') {
         return array('begin' => $twoDaysAgo, 'end' => $tomorrow);
     }
     /* If the period is by week, add the end time to the end date. */
     if ($period == 'thisweek' or $period == 'lastweek') {
         $func = "get{$period}";
         extract(date::$func());
         return array('begin' => $begin, 'end' => $end . ' 23:59:59');
     }
     if ($period == 'thismonth') {
         return date::getThisMonth();
     }
     if ($period == 'lastmonth') {
         return date::getLastMonth();
     }
 }
开发者ID:Wen1750686723,项目名称:zentaopms,代码行数:43,代码来源:model.php

示例2: replaceDynamic

 /**
  Replace dynamic account and date. 
 * 
 * @param  string $query 
 * @access public
 * @return string 
 */
 public function replaceDynamic($query)
 {
     $this->app->loadClass('date');
     $lastWeek = date::getLastWeek();
     $thisWeek = date::getThisWeek();
     $lastMonth = date::getLastMonth();
     $thisMonth = date::getThisMonth();
     $yesterday = date::yesterday();
     $today = date::today();
     if (strpos($query, '$') !== false) {
         $query = str_replace('$@me', $this->app->user->account, $query);
         $query = str_replace("'\$lastMonth'", "'" . $lastMonth['begin'] . "' and '" . $lastMonth['end'] . "'", $query);
         $query = str_replace("'\$thisMonth'", "'" . $thisMonth['begin'] . "' and '" . $thisMonth['end'] . "'", $query);
         $query = str_replace("'\$lastWeek'", "'" . $lastWeek['begin'] . "' and '" . $lastWeek['end'] . "'", $query);
         $query = str_replace("'\$thisWeek'", "'" . $thisWeek['begin'] . "' and '" . $thisWeek['end'] . "'", $query);
         $query = str_replace("'\$yesterday'", "'" . $yesterday . "' and '" . $yesterday . "'", $query);
         $query = str_replace("'\$today'", "'" . $today . "' and '" . $today . "'", $query);
     }
     return $query;
 }
开发者ID:XMGmen,项目名称:zentao,代码行数:27,代码来源:model.php

示例3: getList

 /**
  * Get todo list of a user.
  * 
  * @param  date   $date 
  * @param  string $account 
  * @param  string $status   all|today|thisweek|lastweek|before, or a date.
  * @param  int    $limit    
  * @access public
  * @return void
  */
 public function getList($date = 'today', $account = '', $status = 'all', $limit = 0, $pager = null, $orderBy = "date, status, begin")
 {
     $this->app->loadClass('date');
     $todos = array();
     $date = strtolower($date);
     if ($date == 'today') {
         $begin = date::today();
         $end = $begin;
     } elseif ($date == 'yesterday') {
         $begin = date::yesterday();
         $end = $begin;
     } elseif ($date == 'thisweek') {
         extract(date::getThisWeek());
     } elseif ($date == 'lastweek') {
         extract(date::getLastWeek());
     } elseif ($date == 'thismonth') {
         extract(date::getThisMonth());
     } elseif ($date == 'lastmonth') {
         extract(date::getLastMonth());
     } elseif ($date == 'thisseason') {
         extract(date::getThisSeason());
     } elseif ($date == 'thisyear') {
         extract(date::getThisYear());
     } elseif ($date == 'future') {
         $begin = '2030-01-01';
         $end = $begin;
     } elseif ($date == 'all') {
         $begin = '1970-01-01';
         $end = '2109-01-01';
     } elseif ($date == 'before') {
         $begin = '1970-01-01';
         $end = date::yesterday();
     } else {
         $begin = $end = $date;
     }
     if ($account == '') {
         $account = $this->app->user->account;
     }
     $stmt = $this->dao->select('*')->from(TABLE_TODO)->where('account')->eq($account)->andWhere("date >= '{$begin}'")->andWhere("date <= '{$end}'")->beginIF($status != 'all' and $status != 'undone')->andWhere('status')->in($status)->fi()->beginIF($status == 'undone')->andWhere('status')->ne('done')->fi()->orderBy($orderBy)->beginIF($limit > 0)->limit($limit)->fi()->page($pager)->query();
     /* Set session. */
     $sql = explode('WHERE', $this->dao->get());
     $sql = explode('ORDER', $sql[1]);
     $this->session->set('todoReportCondition', $sql[0]);
     while ($todo = $stmt->fetch()) {
         if ($todo->type == 'task') {
             $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_TASK)->fetch('name');
         }
         if ($todo->type == 'bug') {
             $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_BUG)->fetch('title');
         }
         $todo->begin = date::formatTime($todo->begin);
         $todo->end = date::formatTime($todo->end);
         /* If is private, change the title to private. */
         if ($todo->private and $this->app->user->account != $todo->account) {
             $todo->name = $this->lang->todo->thisIsPrivate;
         }
         $todos[] = $todo;
     }
     return $todos;
 }
开发者ID:XMGmen,项目名称:zentao,代码行数:70,代码来源:model.php

示例4: getList

 /**
  * Get todo list of a user.
  * 
  * @param  string $mode     all|self|assignedToOther|assignedToMe
  * @param  string $account 
  * @param  date   $date     all|today|thisweek|lastweek|before, or a date. 
  * @param  string $status   
  * @param  string $orderBy   
  * @param  object $pager   
  * @access public
  * @return void
  */
 public function getList($mode = 'self', $account = '', $date = 'all', $status = 'all', $orderBy = "date, status, begin", $pager = null)
 {
     if ($account == '') {
         $account = $this->app->user->account;
     }
     $mode = strtolower($mode);
     $this->app->loadClass('date');
     $todos = array();
     if (!is_array($date)) {
         $date = strtolower($date);
     }
     if (is_array($date)) {
         $begin = strtolower($date['begin']);
         $end = strtolower($date['end']);
     } elseif ($date == 'today') {
         $begin = date::today();
         $end = $begin;
     } elseif ($date == 'yesterday') {
         $begin = date::yesterday();
         $end = $begin;
     } elseif ($date == 'thisweek') {
         extract(date::getThisWeek());
     } elseif ($date == 'lastweek') {
         extract(date::getLastWeek());
     } elseif ($date == 'thismonth') {
         extract(date::getThisMonth());
     } elseif ($date == 'lastmonth') {
         extract(date::getLastMonth());
     } elseif ($date == 'thisseason') {
         extract(date::getThisSeason());
     } elseif ($date == 'thisyear') {
         extract(date::getThisYear());
     } elseif ($date == 'future') {
         $begin = '0000-00-00';
         $end = '1970-01-01';
     } elseif ($date == 'all') {
         $begin = '1970-01-01';
         $end = '2109-01-01';
     } elseif ($date == 'before') {
         $begin = '1970-01-01';
         $end = date::yesterday();
     } else {
         $begin = $end = $date;
     }
     $stmt = $this->dao->select('*')->from(TABLE_TODO)->where('1=1')->beginIF($mode == 'self')->andWhere()->markLeft()->where('account')->eq($account)->orWhere('assignedTo')->eq($account)->markRight()->fi()->beginIF($mode == 'assignedtoother')->andWhere('account')->eq($account)->andWhere('assignedTo')->ne($account)->andWhere('assignedTo')->ne('')->fi()->beginIF($mode == 'assignedtome')->andWhere('account')->ne($account)->andWhere('assignedTo')->eq($account)->fi()->andWhere("date >= '{$begin}'")->andWhere("date <= '{$end}'")->beginIF($status != 'all' and $status != 'undone' and $status != 'unclosed')->andWhere('status')->in($status)->fi()->beginIF($status == 'undone')->andWhere('status')->notin('done,closed')->fi()->beginIF($status == 'unclosed')->andWhere('status')->ne('closed')->fi()->orderBy($orderBy)->page($pager)->query();
     /* Set session. */
     $sql = explode('WHERE', $this->dao->get());
     $sql = explode('ORDER', $sql[1]);
     $this->session->set('todoReportCondition', $sql[0]);
     while ($todo = $stmt->fetch()) {
         if ($todo->type == 'task') {
             $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_TASK)->fetch('name');
         }
         if ($todo->type == 'customer') {
             $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_CUSTOMER)->fetch('name');
         }
         if ($todo->type == 'order') {
             $order = $this->dao->select('c.name, o.createdDate')->from(TABLE_ORDER)->alias('o')->leftJoin(TABLE_CUSTOMER)->alias('c')->on('o.customer=c.id')->where('o.id')->eq($todo->idvalue)->fetch();
             $todo->name = $order->name . '|' . date('Y-m-d', strtotime($order->createdDate));
         }
         $todo->begin = date::formatTime($todo->begin);
         $todo->end = date::formatTime($todo->end);
         /* If is private, change the title to private. */
         if ($todo->private and $this->app->user->account != $todo->account) {
             $todo->name = $this->lang->todo->thisIsPrivate;
         }
         $todos[] = $todo;
     }
     return $todos;
 }
开发者ID:leowh,项目名称:colla,代码行数:82,代码来源:model.php


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