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


PHP DateTime::modify方法代码示例

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


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

示例1: 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

示例2: getOpeningAtWarning

 /**
  * 
  * @return string|boolean
  */
 public function getOpeningAtWarning()
 {
     $timeModified = new DateTime($this->time);
     $timeModified->modify($this->warningOpeningDiff);
     $status = $this->getStatus();
     if ($status instanceof StatusModel\Closed && $this->isOpenedByTime($timeModified)) {
         return $this->openingAtByWeekDay($timeModified->format('w'));
     }
     return FALSE;
 }
开发者ID:cothema,项目名称:opening-hours,代码行数:14,代码来源:Status.php

示例3: createComponentExampleOneForm

 public function createComponentExampleOneForm()
 {
     $form = new Form();
     $form->addText('name', "Name:");
     $form->addPassword('password', "Password:");
     $form->addTextArea('textarea', "Textarea");
     $form->addSelect('select', "Select", ['Option 1', 'Option 2']);
     $form->addUpload('upload', 'Upload');
     $form->addCheckbox('checkbox', 'Checkbox');
     $form->addRadioList('radioList', 'Radio list', ['Item A', 'Item B']);
     $form->addCheckboxList('checkboxList', 'Checkbox list,', ['Item A', 'Item B']);
     $form->addText('date', 'Date:')->getControlPrototype()->class('b-date-input');
     $form->addText('datetime', 'Date time:')->getControlPrototype()->class('b-date-input b-date-input--datetime');
     $now = new DateTime();
     $now->modify('+1 day');
     $now->modify('+3 hour');
     $form->setDefaults(['date' => $now, 'datetime' => $now]);
     $form->addSubmit('actionSend', 'Save');
     $form->onSuccess[] = array($this, 'exampleOneFormSubmitted');
     return $form;
 }
开发者ID:Aprila,项目名称:laboratory,代码行数:21,代码来源:FormExamplePresenter.php

示例4: __construct

 /**
  * @param string|null $key
  * @param DateTime|null $date
  * @param boolean|null $active
  */
 public function __construct($key = NULL, DateTime $date = NULL, $active = NULL)
 {
     if (NULL === $key) {
         $this->key = Random::generate(self::KEY_LENGHT);
     } else {
         $this->key = $key;
     }
     if (NULL === $date) {
         $date = new DateTime();
         $date->modify('+5 minutes');
         $this->expiration = $date;
     } else {
         $this->expiration = $date;
     }
     if (NULL === $active) {
         $this->active = TRUE;
     } else {
         $this->active = $active;
     }
 }
开发者ID:pogodi,项目名称:Scud,代码行数:25,代码来源:AccessToken.php

示例5: removeExpired

 /**
  * Auto removes email file when expired.
  * @param  string
  * @return bool
  */
 private function removeExpired($path)
 {
     if ($this->autoremove) {
         $now = new DateTime();
         $file_date = new DateTime('@' . filemtime($path));
         $file_date->setTimezone($now->getTimezone());
         $remove_date = $now->modify($this->autoremove);
         if ($file_date < $remove_date) {
             unlink($path);
             return TRUE;
         }
     }
     return FALSE;
 }
开发者ID:newPOPE,项目名称:FileMailer,代码行数:19,代码来源:MailPanel.php

示例6: getRandArticles

 /**
  * Vraci nahodne clanky
  * @param int $count
  * @param DateTime|NULL $period
  * @return Entities\Article[]
  */
 public function getRandArticles($count = 1, $period = NULL)
 {
     if ($period === NULL) {
         $now = new DateTime();
         $period = $now->modify("-6 month");
     }
     $cacheId = 'rand-' . $count;
     $countAllArticles = (int) $this->countAllArticles();
     $query = "SELECT a FROM \\App\\Model\\Entities\\Article a WHERE a.published = true " . "AND a.publishDate >= :date ";
     $randArticles = $this->em->createQuery($query)->setParameter('date', $period)->setMaxResults($count)->setFirstResult(mt_rand(0, $countAllArticles - 1))->useResultCache(TRUE, 600, $cacheId)->getResult();
     return $randArticles;
 }
开发者ID:krupaj,项目名称:my-blog,代码行数:18,代码来源:ArticleRepository.php


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