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


PHP DateTime::format方法代码示例

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


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

示例1: distributionPlanIsCreated

 public function distributionPlanIsCreated()
 {
     $date = new DateTime();
     $from = '"' . $date->format('Y.m.d') . ' 00:00:00"';
     $to = '"' . $date->format('Y.m.d') . ' 23:59:00"';
     $data = $this->db->select('*')->from($this->table)->where('date>' . $from . ' AND date<' . $to)->fetchAll();
     if (isset($data[0])) {
         return true;
     }
     return false;
 }
开发者ID:ludik1,项目名称:transport_company,代码行数:11,代码来源:OrdersModel.php

示例2: create

 /**
  * @param \App\Model\Entities\Article|NULL $article Clanek k editaci
  * @return Form 
  */
 public function create($article = NULL, $tags = [])
 {
     $form = $this->baseFormFactory->create();
     $form->addText('title', 'system.postName')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']));
     $form->addText('description', 'system.postDescription')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']));
     $form->addCheckbox('published', 'system.isPublished');
     //chybi publish_date - datum zverejneni
     $today = new DateTime();
     $form->addText('publishDate', 'system.published')->setType('datetime-local')->setDefaultValue($today->format('d. m. Y, H:i'));
     //->setAttribute('placeholder', 'd. m. Y, H:i (den. měsíc. rok');
     $form->addMultiSelect('tags', new Phrase('system.tag', 2))->setItems($tags);
     $form->addUpload('image', 'system.postImage')->addCondition(Form::FILLED)->addRule(Form::IMAGE, $form->getTranslator()->translate('system.formImage', ['item' => '%label']));
     $form->addText('imageSource', 'system.postImageSource');
     $form->addTextArea('content', 'system.postContent')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']))->setAttribute('rows', 10);
     $form->addSubmit('send', 'system.save');
     //id, vychozi hodnoty pri editaci
     $form->addHidden('id');
     if ($article !== NULL) {
         $defaults = $this->getDefaults($article);
         $form->setDefaults($defaults);
     }
     $form->onValidate[] = [$this, 'validateForm'];
     $form->onSuccess[] = [$this, 'formSucceeded'];
     return $form;
 }
开发者ID:krupaj,项目名称:my-blog,代码行数:29,代码来源:ArticleFormFactory.php

示例3: create

 /**
  * @param array $types
  * @param \App\Model\Entities\Vote $vote
  * @return Form 
  */
 public function create($types, $vote = NULL)
 {
     $form = $this->baseFormFactory->create();
     $form->addText('question', 'system.voteQuestion')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']));
     $form->addSelect('type', 'system.voteType')->setItems($types)->setPrompt('Zvolte typ dotazu')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']));
     $form->addText('expiration', 'system.voteExpiration')->setType('datetime-local')->setAttribute('placeholder', 'd. m. Y, H:i (den. měsíc. rok, hodina:minuta');
     $options = $form->addDynamic('options', function (Container $option) {
         $option->addText('option', 'system.voteOption');
         $option->addSubmit('remove', 'system.delete')->addRemoveOnClick();
     }, 1);
     $options->addSubmit('add', 'system.new')->setValidationScope(FALSE)->addCreateOnClick();
     $form->addSubmit('send', 'system.save');
     $form->addHidden('id');
     if ($vote) {
         $defaults = $this->getDefaults($vote);
         $form->setDefaults($defaults);
         $options->setValues($defaults['options']);
     } else {
         $today = new DateTime();
         $today->modify('+6 month');
         $default = ['expiration' => $today->format(self::$dateMask)];
         $form->setDefaults($default);
     }
     $form->onValidate[] = [$this, 'validateForm'];
     $form->onSuccess[] = [$this, 'formSucceeded'];
     return $form;
 }
开发者ID:krupaj,项目名称:my-blog,代码行数:32,代码来源:VoteFormFactory.php

示例4: generate

 /**
  * Generate table
  */
 protected function generate()
 {
     $days = $this->getSpecificDays();
     $table = new Table\Sheet();
     $line = new Table\Line();
     $lastTimeFrom = NULL;
     $lastTimeTo = NULL;
     $lastDay = NULL;
     $lastTags = NULL;
     $now = new DateTime();
     foreach ($days as $day) {
         $timeFrom = (new FilterTime\Def($day->openTime))->output;
         $timeTo = (new FilterTime\Def($day->closeTime))->output;
         if ($lastTimeFrom === $timeFrom && $lastTimeTo === $timeTo && $this->tagsAreSame($lastTags, $day->tags) && $lastDay !== NULL && (int) $lastDay->day->diff($day->day)->format('%r%a') === 1) {
             $line->dateTo = $day->day;
         } else {
             $lastTimeTo !== NULL && $table->addLine($line);
             $line = new Table\Line();
             $line->dateFrom = $day->day;
             $line->dateTo = $day->day;
             $line->tags = $day->tags;
             $this->lineAddTime($line, $timeFrom, $timeTo);
         }
         if ($day->day->format('Y-m-d') === $now->format('Y-m-d')) {
             $line->setActive();
         }
         $lastTags = $day->tags;
         $lastTimeFrom = $timeFrom;
         $lastTimeTo = $timeTo;
         $lastDay = $day;
     }
     $lastTimeTo !== NULL && $table->addLine($line);
     $this->generatedTable = $table;
 }
开发者ID:cothema,项目名称:opening-hours,代码行数:37,代码来源:SpecificDays.php

示例5: isOk

 public function isOk()
 {
     $now = new DateTime();
     if ($this->active && intval($this->getExpiration()->format("U")) > intval($now->format("U"))) {
         return TRUE;
     }
     return FALSE;
 }
开发者ID:pogodi,项目名称:Scud,代码行数:8,代码来源:AccessToken.php

示例6: update

 public function update(Items\Base $item, $data)
 {
     if (preg_match('~^\\d{1,2}[/.]{1}[ ]{0,1}\\d{1,2}[/.]{1}[ ]{0,1}\\d{4}$~', $data, $arr)) {
         $dateArr = preg_split('/[.\\/]{1}[ ]{0,1}/s', $arr[0]);
         $date = new Nette\Utils\DateTime($dateArr[2] . '-' . $dateArr[1] . '-' . $dateArr[0]);
         $data = $date->format('Y-m-d');
     }
     return $data;
 }
开发者ID:trejjam,项目名称:contents,代码行数:9,代码来源:DateSubType.php

示例7: toRequestArray

 /**
  * @return array of string
  * @throws NoQueryException
  */
 public function toRequestArray()
 {
     $ret = array();
     $ret[self::$ID_DT] = $this->dt->format(Ares::REQUEST_DATE_FORMAT);
     $ret[self::$ID_OUTPUT_FORMAT] = $this->outputFormat;
     $ret[self::$ID_REQUEST_TYPE] = $this->requestType;
     $ret[self::$ID_REQUESTS_COUNT] = $this->queryCount;
     $ret[self::$ID_EMAIL] = $this->email;
     $ret[self::$ID_REQUEST] = array();
     if (!count($this->queries)) {
         throw new NoQueryException();
     }
     foreach ($this->queries as $query) {
         /* @var $query \Sasule\Ares\Query */
         $ret[self::$ID_REQUEST][] = $query->toRequestArray();
     }
     return $ret;
 }
开发者ID:sasule,项目名称:ares,代码行数:22,代码来源:RequestWrapper.php

示例8: getControlSettings

 /**
  * Get settings for control
  *
  * @return array
  */
 protected function getControlSettings()
 {
     $settings = ['format' => $this->getDateTimeFormat(), 'daysOfWeekDisabled' => $this->daysOfWeekDisabled, 'autoclose' => $this->autoClose, 'startView' => $this->startView, 'minViewMode' => $this->minViewMode, 'todayHighlight' => $this->todayHighlight, 'inline' => $this->inline, 'multidate' => $this->multidate, 'multidateSeparator' => $this->multidateSeparator];
     if (!empty($this->datesDisabled)) {
         $dates = [];
         foreach ($this->datesDisabled as $dateTime) {
             $dates[] = $dateTime->format($this->getDateTimeFormat(TRUE));
         }
         $settings['datesDisabled'] = $dates;
     }
     if ($this->startDateTime != NULL) {
         $settings['startDate'] = $this->startDateTime->format($this->getDateTimeFormat(TRUE));
     }
     if ($this->endDateTime != NULL) {
         $settings['endDate'] = $this->endDateTime->format($this->getDateTimeFormat(TRUE));
     }
     return $settings;
 }
开发者ID:vojtys,项目名称:bootstrap-datepicker,代码行数:23,代码来源:DatePickerBase.php

示例9: toRequestArray

 /**
  * @return array of string
  * @throws QueryMissingKeyPartException
  */
 public function toRequestArray()
 {
     $ret = array();
     if ($this->keyPart instanceof KeyPart) {
         $ret[self::$ID_HELPER_ID] = $this->helperId;
         if ($this->checkUsable($this->searchType)) {
             $ret[self::$ID_SEARCH_TYPE] = $this->searchType;
         }
         $ret[self::$ID_KEY_PART] = $this->keyPart->toRequestArray();
         if ($this->checkUsable($this->city)) {
             $ret[self::$ID_CITY] = $this->city;
         }
         if ($this->dtValid instanceof DateTime) {
             $ret[self::$ID_DT_VALID] = $this->dtValid->format(Ares::REQUEST_DATE_FORMAT);
         }
         if ($this->checkUsable($this->registerType)) {
             $ret[self::$ID_REGISTER_TYPE] = $this->registerType;
         }
         $ret[self::$ID_MAX_COUNT] = $this->maxCount;
     } else {
         throw new QueryMissingKeyPartException();
     }
     return $ret;
 }
开发者ID:sasule,项目名称:ares,代码行数:28,代码来源:Query.php

示例10: getDay

 /**
  * 
  * @param DateTime|NULL $day
  * @return WeekDay
  */
 public function getDay(DateTime $day)
 {
     if (isset($this->specificDays[$day->format('Y-m-d')])) {
         return $this->specificDays[$day->format('Y-m-d')];
     } elseif (isset($this->openingHours[(string) $day->format('w')])) {
         return $this->openingHours[(string) $day->format('w')];
     }
     return NULL;
 }
开发者ID:cothema,项目名称:opening-hours,代码行数:14,代码来源:OpeningHours.php

示例11: ByPoint

 /**
  * Sestavi poradi bodu nezavisle na discipline v ramci oddilu.
  * @param number $course Delka bazenu.
  * @return object $data Poradi bodu.
  */
 public function ByPoint($course)
 {
     $data = $this->database->query('
         select  -- 4. select
             @rownum := @rownum + 1 AS rank,
             sel_2.body, 
             sel_2.prijmeni, 
             sel_2.jmeno, 
             sel_2.rocnik,
             sel_2.styl,
             sel_2.cas,
             sel_2.datum,
             sel_2.zavod
           from
           (
             select -- 2. select
               sel_1.body as body, 
               plavci.surname as prijmeni, 
               plavci.firstname as jmeno, 
               plavci.year as rocnik,
               styly.id as styl,
               cas.time as cas,
               zavody.date as datum,
               zavody.name as zavod
             from
               sm_event zavody,
               sm_stroke styly,
               sm_swimmer plavci,
               sm_time cas,
               (
                 select  -- 1. select
                   a.id_swimmer as plavec,                  
                   max(a.point) as body
                 from
                   sm_time a,
                   sm_event b,
                   sm_swimmer c
                 where
                   a.id_event = b.id and
                   a.id_swimmer = c.id and                  
                   b.lcm = ?
                 group by
                   a.id_swimmer  
               ) sel_1
             where
               cas.id_swimmer = sel_1.plavec and
               cas.point = sel_1.body and              
               cas.id_event = zavody.id and
               cas.id_stroke = styly.id and
               cas.id_swimmer = plavci.id and
               
               zavody.lcm = ? 
             group by
               sel_1.body
             order by
               sel_1.body desc
           ) sel_2,
           (SELECT @rownum := 0) sel_3 -- 3. select', $course, $course)->fetchAll();
     foreach ($data as $row) {
         $formated_date = new DateTime($row->datum);
         $row->datum = $formated_date->format('d. m. Y');
     }
     return $data;
 }
开发者ID:jave007,项目名称:iSAM,代码行数:69,代码来源:StatisticManager.php

示例12: renderCreate

 public function renderCreate()
 {
     $dateNow = new DateTime();
     $d = array('platneOd' => $dateNow->format(self::$dateFormat));
     $this['nastenkaForm']->setDefaults($d);
 }
开发者ID:bkralik,项目名称:BarakIS,代码行数:6,代码来源:NastenkaPresenter.php

示例13: footer

 public static function footer()
 {
     $now = new DateTime();
     return "\n" . "\n" . "-- {$now->format('Y-m-d H:i:s')}\n";
 }
开发者ID:filsedla,项目名称:dbtool,代码行数:5,代码来源:Data.php

示例14: timeAgo

 public function timeAgo(DateTime $d)
 {
     return Html::el('time')->setText($d->format('j.n.Y H:i'))->addAttributes(['datetime' => $d->format('c')]);
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:4,代码来源:Filters.php

示例15: setValidated

 public function setValidated($id)
 {
     $now = new \Nette\Utils\DateTime();
     $this->localLoginModel->update($id, array("validated" => $now->format('Y-m-d H:i:s')));
 }
开发者ID:rawac,项目名称:agenda,代码行数:5,代码来源:LocalAuthenticator.php


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