当前位置: 首页>>代码示例>>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;未经允许,请勿转载。