當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。