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


PHP DateTime::createFromFormat方法代码示例

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


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

示例1: handleUpdateDate

 public function handleUpdateDate($firstName, $surName, $mail, $date, $type, $spz, $tel, $carMakes, $carModel, $additionalInfo)
 {
     if ($this->isAjax()) {
         $this->defaults = array('firstName' => $firstName, 'surName' => $surName, 'mail' => $mail, 'date' => $date, 'type' => $type, 'spz' => $spz, 'telNumber' => $tel, 'carMakes' => $carMakes, 'carModel' => $carModel, 'additionalInfo' => $additionalInfo);
         $day = date('N', strtotime(str_replace(' ', '', $date)));
         $multiplier = 0;
         switch ($type) {
             case 5:
                 $multiplier = 1;
                 break;
             case 6:
                 $multiplier = 3;
                 break;
             case 7:
                 $multiplier = 3;
                 break;
         }
         if ($day != 7) {
             $this->timeIntervals = $this->reservationManager->getIntervalsForDay(Nette\Utils\DateTime::createFromFormat('d. m. Y', $date), $multiplier);
         } else {
             $this->timeIntervals = array(Model\ExceptionMessages::NOT_DEFINED => 'Zavřeno');
         }
         $this->redrawControl('addReservationSnippet');
     }
 }
开发者ID:hondem,项目名称:mcpneu,代码行数:25,代码来源:ReservationPresenter.php

示例2: sinceDate

 public function sinceDate($placeId, $date = null, $count = 7)
 {
     $files = array();
     $dir = dir($this->resolveDir($placeId));
     if ($dir === false) {
         return array();
     }
     while (false != ($entry = $dir->read())) {
         if (strrpos($entry, '.') != 10 || strrchr($entry, '.') != '.tmp') {
             continue;
         }
         // add filename without ext
         $files[] = strstr($entry, '.', true);
     }
     sort($files);
     $datePlain = is_int($date) ? date('Y-m-d', $date) : $date;
     $pos = 0;
     self::binarySearch($datePlain, $files, 'strcmp', $pos);
     $selection = array_slice($files, $pos, $count);
     $result = array();
     foreach ($selection as $item) {
         $itemDate = DateTime::createFromFormat('Y-m-d', $item)->getTimestamp();
         $result[$itemDate] = $this->forDate($placeId, $item);
     }
     return $result;
 }
开发者ID:arcao,项目名称:menza-nette,代码行数:26,代码来源:MealMenu.php

示例3: getValue

 /**
  * Returns date
  *
  * @return mixed
  */
 public function getValue()
 {
     if (strlen($this->value) > 0) {
         return DateTime::createFromFormat($this->format, $this->value);
     }
     return $this->value;
 }
开发者ID:bombush,项目名称:NatsuCon,代码行数:12,代码来源:TbDatePicker.php

示例4: createFromArray

 /**
  * @param array $data
  * @return Address
  */
 public static function createFromArray(array $data)
 {
     $data['first_seen'] = DateTime::createFromFormat(DateTime::ATOM, $data['first_seen']);
     $data['last_seen'] = DateTime::createFromFormat(DateTime::ATOM, $data['last_seen']);
     $address = new Address();
     $address->data = $data;
     return $address;
 }
开发者ID:brosland,项目名称:blocktrail,代码行数:12,代码来源:Address.php

示例5: createFromArray

 /**
  * @param array $data
  * @return Block
  */
 public static function createFromArray(array $data)
 {
     $data['block_time'] = DateTime::createFromFormat(DateTime::ATOM, $data['block_time']);
     $data['arrival_time'] = DateTime::createFromFormat(DateTime::ATOM, $data['arrival_time']);
     $block = new Block();
     $block->data = $data;
     return $block;
 }
开发者ID:brosland,项目名称:blocktrail,代码行数:12,代码来源:Block.php

示例6: create

 /**
  * @return DataGrid
  */
 public function create()
 {
     $grid = $this->gridFactory->create();
     $grid->addColumnText("id", "ID");
     $grid->addColumnText("name", "Name")->setFilterText();
     $grid->addColumnDateTime("date", "Date")->setFilterDate();
     $grid->setDataSource([["id" => 1, "name" => "Karel", "date" => DateTime::createFromFormat("d.m.Y", "10.10.2000")], ["id" => 2, "name" => "Pavel", "date" => new DateTime()]]);
     return $grid;
 }
开发者ID:chapcz,项目名称:sandbox,代码行数:12,代码来源:GridTester.php

示例7: __construct

 /**
  * @param string $email
  * @param User|null $sender
  */
 public function __construct($email, User $sender = null)
 {
     $this->setEmail($email);
     $this->sender = $sender;
     $this->generateToken();
     $startDate = \Nette\Utils\DateTime::createFromFormat('!Y-m-d', date('Y-m-d'));
     $this->setValidity($startDate);
     $this->lastSending = $startDate;
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:13,代码来源:Invitation.php

示例8: getValue

 /**
  * Returns control's value.
  * @return string
  */
 public function getValue()
 {
     $value = parent::getValue();
     // convert to Nette\Utils\DateTime
     if ($value && is_string($value)) {
         $format = "d.m.Y";
         $value = DateTime::createFromFormat($format, $value);
     }
     return $value ? $value : NULL;
 }
开发者ID:mepatek,项目名称:application,代码行数:14,代码来源:DateFormControl.php

示例9: getValue

 /**
  * Returns date
  *
  * @return mixed
  */
 public function getValue()
 {
     if (strlen($this->value) > 0) {
         $date = DateTime::createFromFormat($this->format, $this->value);
         if ($date === FALSE) {
             $this->addError($this->getValueErrorMessage());
             return FALSE;
         }
         return $date->setTime(0, 0, 0);
     }
     return $this->value;
 }
开发者ID:radekdostal,项目名称:nette-datetimepicker,代码行数:17,代码来源:DatePicker.php

示例10: convertToPHPValue

 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === NULL) {
         return NULL;
     } elseif ($value instanceof \DateTime) {
         return NetteDateTime::from($value);
     }
     $val = NetteDateTime::createFromFormat($platform->getDateTimeFormatString(), $value);
     if (!$val) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString());
     }
     return NetteDateTime::from($val);
 }
开发者ID:ATouhou,项目名称:db-benchmark,代码行数:13,代码来源:DateTimeType.php

示例11: formSucceeded

 public function formSucceeded(RegistrationForm $form)
 {
     if ($form['remember']->getValue()) {
         $this->user->setExpiration('14 days', false);
     } else {
         $this->user->setExpiration('20 minutes', true);
     }
     $date = DateTime::createFromFormat('Y-m-d', date("Y-m-d"));
     try {
         $this->manager->add($form['username']->getValue(), $form['password']->getValue(), $form['email']->getValue(), $date);
         $this->user->login($form['username']->getValue(), $form['password']->getValue());
     } catch (Nette\Security\AuthenticationException $e) {
         $form->addError($e->getMessage());
     }
 }
开发者ID:04EO,项目名称:hup-nette,代码行数:15,代码来源:RegistrationFormFactory.php

示例12: validateValue

 /**
  * @Todo Separate this method to some DateTime Utils class
  *
  * @param string $value
  * @param string $pattern
  * @return DateTime
  * @throws DateTimeParseException
  */
 private static function validateValue($value, $pattern)
 {
     $value = static::strip($value);
     if (($parsed = DateTime::createFromFormat($pattern, $value)) === FALSE) {
         throw new DateTimeParseException("Value does not match desired format: '{$pattern}'.");
     }
     $error = DateTime::getLastErrors();
     if ($error['error_count'] > 0 || $error['warning_count'] > 0) {
         throw new DateTimeParseException('Invalid date given. ' . 'Errors: ' . implode(', ', $error['errors']) . ' ' . 'Warnings: ' . implode(', ', $error['warnings']));
     }
     $strippedCrossCheckValue = static::strip($parsed->format($pattern));
     if ($value !== $strippedCrossCheckValue) {
         throw new DateTimeParseException("Invalid date given. Check value does not match original. ['{$strippedCrossCheckValue}' !== '{$value}']");
     }
     return $parsed;
 }
开发者ID:pilec,项目名称:nette-date-time-input,代码行数:24,代码来源:SimpleDateTimeFormatter.php

示例13: handleRemoveItem

 /**
  * @secured
  */
 public function handleRemoveItem($day)
 {
     $this->checkDayValue($day);
     try {
         $this->itemFacade->removeListingItem($day, $this->listing);
         if ($this->presenter->isAjax()) {
             $item = new FillingItem(DateTime::createFromFormat('d.m.Y', $day . '.' . $this->listing->getMonth() . '.' . $this->listing->getYear()));
             $this['itemsTable']->refreshTable([$item]);
         } else {
             $this->flashMessage('Řádek byl vymazán.', 'success');
             $this->redirect('this');
         }
     } catch (ListingNotFoundException $lnf) {
         $this->flashMessage('Výčetka, kterou se snažíte upravit, nebyla nalezena.');
         $this->redirect('Listing:overview');
     }
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:20,代码来源:ListingTableControl.php

示例14: createFromArray

 /**
  * @param array $data
  * @return Transaction
  */
 public static function createFromArray(array $data)
 {
     $transaction = new Transaction();
     foreach ($data['inputs'] as $key => $inputData) {
         $transaction->inputs[$key] = Input::createFromArray($inputData);
     }
     foreach ($data['outputs'] as $key => $outputData) {
         $transaction->outputs[$key] = Output::createFromArray($outputData);
     }
     unset($data['inputs']);
     unset($data['outputs']);
     $data['first_seen_at'] = DateTime::createFromFormat(DateTime::ATOM, $data['first_seen_at']);
     $data['last_seen_at'] = DateTime::createFromFormat(DateTime::ATOM, $data['last_seen_at']);
     $data['block_time'] = DateTime::createFromFormat(DateTime::ATOM, $data['block_time']);
     $transaction->data = $data;
     return $transaction;
 }
开发者ID:brosland,项目名称:blocktrail,代码行数:21,代码来源:Transaction.php

示例15: getValue

 /**
  * @return DateTime|NULL
  */
 public function getValue()
 {
     if (!($value = $this->value)) {
         return NULL;
     }
     if ($value instanceof \DateTime || is_int($value)) {
         return DateTime::from($value);
     }
     try {
         return DateTime::createFromFormat($this->format, $this->value);
     } catch (\Exception $e) {
     }
     if ($time = strtotime($value)) {
         return DateTime::from($value);
     }
     return NULL;
 }
开发者ID:juniwalk,项目名称:form,代码行数:20,代码来源:DateTimePicker.php


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