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


PHP format::datetime_parts方法代碼示例

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


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

示例1: next_run_date

 /**
  * Next run datetime
  *
  * @param mixed $datetime
  * @return string
  */
 public function next_run_date($datetime = null)
 {
     $result = null;
     if (empty($datetime)) {
         $datetime = format::now('unix');
     } else {
         if (!is_numeric($datetime)) {
             $datetime = strtotime($datetime);
         }
     }
     $parts = format::datetime_parts($datetime);
     for ($year = $parts['year']; $year <= self::$slot_stats[6]['max']; $year++) {
         // check if we are in range
         if (!(in_array('*', $this->parsed_expression['year']) || in_array($year, $this->parsed_expression['year']))) {
             continue;
         }
         for ($month = 1; $month <= 12; $month++) {
             // check if we are in range
             if (!(in_array('*', $this->parsed_expression['month']) || in_array($month, $this->parsed_expression['month']))) {
                 continue;
             }
             for ($day = 1; $day <= 31; $day++) {
                 // check if we are in range
                 if (!(in_array('*', $this->parsed_expression['day']) || in_array($day, $this->parsed_expression['day']))) {
                     continue;
                 }
                 // check weekday
                 $weekday = date('w', mktime(0, 0, 0, $month, $day, $year));
                 if (!(in_array('*', $this->parsed_expression['weekday']) || in_array($weekday, $this->parsed_expression['weekday']))) {
                     continue;
                 }
                 // loop through hours
                 for ($hour = 0; $hour <= 23; $hour++) {
                     // check if we are in range
                     if (!(in_array('*', $this->parsed_expression['hour']) || in_array($hour, $this->parsed_expression['hour']))) {
                         continue;
                     }
                     // loop though minutes
                     for ($minute = 0; $minute <= 59; $minute++) {
                         $date = mktime($hour, $minute, 0, $month, $day, $year);
                         if ($date < $datetime) {
                             continue;
                         } else {
                             // check if we are in range
                             if (!(in_array('*', $this->parsed_expression['minute']) || in_array($minute, $this->parsed_expression['minute']))) {
                                 continue;
                             }
                             // check the rest
                             $result = format::datetime($date);
                             goto exit1;
                         }
                     }
                 }
             }
         }
     }
     exit1:
     return $result;
 }
開發者ID:volodymyr-volynets,項目名稱:backend,代碼行數:65,代碼來源:expression.php


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