當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateUtil::init方法代碼示例

本文整理匯總了PHP中DateUtil::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateUtil::init方法的具體用法?PHP DateUtil::init怎麽用?PHP DateUtil::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DateUtil的用法示例。


在下文中一共展示了DateUtil::init方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: save

 /**
  * @see	Form::save()
  */
 public function save()
 {
     parent::save();
     // build timestamps
     $untilDate = intval(gmmktime(24, 0, 0, $this->untilMonth, $this->untilDay, intval($this->untilYear)));
     $fromDate = intval(gmmktime(0, 0, 0, $this->fromMonth, $this->fromDay, intval($this->fromYear)));
     // build sql date format
     switch ($this->groupBy) {
         case 'day':
             $sqlDateFormat = '%Y%m%d';
             break;
         case 'week':
             $sqlDateFormat = '%Y%u';
             break;
         default:
             $sqlDateFormat = '%Y%m';
     }
     // get selected timezone
     DateUtil::init();
     $timezoneStr = str_replace('.', ':', sprintf("%+06.2f", DateUtil::$timezone));
     // build sql
     $results = array();
     $max = 0;
     $sql = "SELECT\t\tCOUNT(*) AS count, \n\t\t\t\t\tDATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(" . $this->types[$this->type]->dateFieldName . "),@@session.time_zone,'" . escapeString($timezoneStr) . "'),'" . $sqlDateFormat . "') AS groupBy,\n\t\t\t\t\tAVG(" . $this->types[$this->type]->dateFieldName . ") AS date\n\t\t\tFROM\t\t" . $this->types[$this->type]->tableName . "\n\t\t\tWHERE\t\t" . ($this->userObj !== null && $this->types[$this->type]->userFieldName ? $this->types[$this->type]->userFieldName . " = " . $this->userObj->userID . " AND" : '') . "\n\t\t\t\t\t" . $this->types[$this->type]->dateFieldName . " > " . $fromDate . "\n\t\t\t\t\tAND " . $this->types[$this->type]->dateFieldName . " < " . $untilDate . "\n\t\t\tGROUP BY \tgroupBy\n\t\t\tORDER BY\t" . $this->sortField . " " . $this->sortOrder;
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $results[] = $row;
         if ($row['count'] > $max) {
             $max = $row['count'];
         }
     }
     WCF::getTPL()->assign(array('results' => $results, 'max' => $max, 'dateFormat' => WCF::getLanguage()->get($this->groupBy == 'day' ? 'wcf.global.dateFormatLocalized' : 'wcf.acp.stats.dateFormat.' . $this->groupBy)));
 }
開發者ID:joaocustodio,項目名稱:EmuDevstore-1,代碼行數:36,代碼來源:StatsForm.class.php


注:本文中的DateUtil::init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。