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


PHP DateTime::diff方法代码示例

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


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

示例1: getSpecificDays

 /**
  * 
  * @param integer $nextDays
  * @return array
  */
 public function getSpecificDays($nextDays = 30, $previousDays = 0)
 {
     $now = new \DateTime();
     return array_filter($this->specificDays, function ($val, $key) use($now, $nextDays, $previousDays) {
         $time = new \DateTime($key);
         $diff = (int) $now->diff($time)->format('%r%a');
         return $diff >= $previousDays * -1 && $diff <= $nextDays;
     }, ARRAY_FILTER_USE_BOTH);
 }
开发者ID:cothema,项目名称:opening-hours,代码行数:14,代码来源:OpeningHours.php

示例2: renderEmail

 public function renderEmail()
 {
     $person = $this->userManager->get($this->user->getId());
     $this->template->person = $person;
     $now = new DateTime();
     $diff = $now->diff($person->change_email_requested);
     if ($diff->h < 1 && $diff->days == 0) {
         $this->template->openStepTwo = TRUE;
     }
 }
开发者ID:aprila,项目名称:app-knowledge-base,代码行数:10,代码来源:UserSettingsPresenter.php

示例3: validityCheck

 public function validityCheck($form)
 {
     $values = $form->getValues();
     if ($values->password != $values->password2) {
         $form->addError('Obě varianty hesla musí být stejné.');
     }
     $bdate = new \Nette\Utils\DateTime($values->birthdate);
     $diff = $bdate->diff(new \Nette\Utils\DateTime());
     $diff = $diff->format('%d');
     if ($diff < 7) {
         $form->addError('Uživatelé by měli být starší než jeden týden. ' . $diff . ' dní je příliš málo.');
     }
     $data = $this->model->getSelection()->where(array("email" => $values->email))->fetch();
     if ($data) {
         $form->addError('Email ' . $values->email . ' je již používán.');
     }
 }
开发者ID:rawac,项目名称:agenda,代码行数:17,代码来源:RegistrationForm.php

示例4: processDownloadRequestCreation

 /**
  * process wigle request and determine what to do
  * returns status code
  *
  * @param Coords $coords
  * @param int       $idSource
  * @return bool|string
  */
 public function processDownloadRequestCreation($coords, $idSource)
 {
     $coords = new Coords(round($coords->getLatStart() - 0.005, 2), round($coords->getLatEnd() + 0.005, 2), round($coords->getLonStart() - 0.005, 2), round($coords->getLonEnd() + 0.005, 2));
     $existingRequest = $this->getRequestAlreadyExistingInLatLngRange($coords, $idSource);
     if ($existingRequest) {
         // nalezeno
         $er = $existingRequest->toArray();
         // pokud processed = N pak je ve fronte a neni stazeno
         if ($er["processed"] == "N") {
             return self::STATE_ERR_ALREADY_IN_QUEUE;
         } else {
             $today = new DateTime();
             $diff = $today->diff($er["processed_date"]);
             if ($diff->days < self::MIN_DAYS_BEFORE_UPDATE_AREA) {
                 return self::STATE_ERR_RECENTLY_DOWNLOADED;
             } else {
                 return $this->addAllNotDownloadedRequests($coords, $idSource);
             }
         }
     } else {
         return $this->addAllNotDownloadedRequests($coords, $idSource);
     }
 }
开发者ID:romanvlcek,项目名称:wifimap,代码行数:31,代码来源:DownloadRequest.php

示例5: isTokenValid

 /**
  * @param string $token
  * @param int $expirationTime
  * @return bool
  */
 public function isTokenValid($token, $expirationTime = 10)
 {
     try {
         $user = $this->read()->where("recoveryToken", $token)->limit(1)->fetch();
         if ($user) {
             $current = new DateTime();
             $diff = $current->diff(new DateTime($user->getRecoveryTokenInserted()));
             if ($diff->format("%h") == 0 && $diff->format("%i") <= $expirationTime) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } catch (\PDOException $e) {
         return false;
     }
 }
开发者ID:vipercz,项目名称:sandbox,代码行数:24,代码来源:UserRepository.php

示例6: changeEmailStepTwo

 /**
  * @param $id int
  * @param $tokenOne string
  * @param $tokenTwo string
  */
 public function changeEmailStepTwo($id, $tokenOne, $tokenTwo)
 {
     $person = $this->get($id);
     $now = new DateTime();
     $diff = $now->diff($person->change_email_requested);
     if ($diff->h >= 1) {
         // todo throw exception
         return FALSE;
     }
     $verified = FALSE;
     if (Passwords::verify($tokenOne, $person->change_email_tokenOne)) {
         if (Passwords::verify($tokenTwo, $person->change_email_tokenTwo)) {
             $verified = TRUE;
         }
     } else {
         // swithed codes?
         if (Passwords::verify($tokenOne, $person->change_email_tokenTwo)) {
             if (Passwords::verify($tokenTwo, $person->change_email_tokenOne)) {
                 $verified = TRUE;
             }
         }
     }
     if (!$verified) {
         // todo throw excaption
         return FALSE;
     }
     $newEmail = $person->change_email;
     $data = array('email' => $newEmail, 'change_email' => '', 'change_email_tokenOne' => '', 'change_email_tokenTwo' => '', 'change_email_requested' => '');
     $this->get($id)->update($data);
     return $newEmail;
 }
开发者ID:Aprila,项目名称:app-developer-desktop,代码行数:36,代码来源:UserManager.php


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