本文整理汇总了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;
}