當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateTime::add方法代碼示例

本文整理匯總了PHP中Nette\Utils\DateTime::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateTime::add方法的具體用法?PHP DateTime::add怎麽用?PHP DateTime::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nette\Utils\DateTime的用法示例。


在下文中一共展示了DateTime::add方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setLastAndNextRun

 /**
  * Calculate and set last and next run
  */
 public function setLastAndNextRun()
 {
     // set lastRun, lastSuccess
     $this->lastRun = new DateTime();
     $this->nextRun = null;
     // find nextTime to run
     foreach ($this->conditions as $condition) {
         $nextRun = $condition->getNextRunTime($this->lastRun);
         // if nextRun less than lastRun set lastRun + 1min
         if ($nextRun < $this->lastRun) {
             $nextRun = $this->lastRun->add(new \DateInterval("PT1M"));
         }
         if ($this->nextRun) {
             $this->nextRun = $this->nextRun > $nextRun ? $nextRun : $this->nextRun;
         } else {
             $this->nextRun = $nextRun;
         }
     }
 }
開發者ID:Mepatek,項目名稱:taskmanager,代碼行數:22,代碼來源:Task.php

示例2: resetPasswordToken

 /**
  * Generate token for change password.
  *
  * @param string $email
  *
  * @return string|false
  */
 public function resetPasswordToken($email)
 {
     $user = $this->userRepository->findOneBy(["email" => $email]);
     // userExist?
     if ($user) {
         $tokenExpires = new DateTime();
         $tokenExpires->add(new \DateInterval('PT60M'));
         // 60 min for expire
         $token = $this->userRepository->resetPasswordToken($user, $tokenExpires);
         return $token ? $token : false;
     } else {
         return false;
     }
 }
開發者ID:mepatek,項目名稱:usermanager,代碼行數:21,代碼來源:Authenticator.php

示例3: setStateRunning

 /**
  * Lock table for read only and set task state to running (State = 1)
  *
  * @param Task $task
  *
  * @return bool
  */
 public function setStateRunning(Task $task)
 {
     $table = $this->getTable();
     if ($task->maxExecutionTimeInSecond) {
         $exceedDateTime = new Nette\Utils\DateTime();
         $task->exceedDateTime = $exceedDateTime->add(new \DateInterval("PT" . $task->maxExecutionTimeInSecond . "S"));
     }
     $cnt = $table->where("TaskID", $task->id)->where("State", $task->state)->update(["State" => 1, "ExceedDateTime" => $task->exceedDateTime]);
     if ($cnt > 0) {
         $task->state = 1;
     }
     return $cnt > 0;
 }
開發者ID:Mepatek,項目名稱:taskmanager,代碼行數:20,代碼來源:TaskNetteDatabaseMapper.php


注:本文中的Nette\Utils\DateTime::add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。