美文网首页
PHP 获取最近几天有效工作日的时间

PHP 获取最近几天有效工作日的时间

作者: 侯晓彬 | 来源:发表于2020-03-04 10:35 被阅读0次
 $day_interval = 3;
 $time_date = ["0", "1", "2", "3", "4", "5", "6"];
 $this::timeQuantum($day_interval, $time_date, $result);
 public static function timeQuantum($day_interval, &$time_date = array(), &$result = array())
 {
        static $i       = 0;
        static $include = 0;
        $i++;
        if ($include < $day_interval) {  //如果小于最近的天数
            $week = strval(date("w", strtotime(date("Y-m-d", strtotime("+$i day")))));//获取是周几
            if (in_array($week, $time_date)) {//如果是工作日执行
                $include++;
                $dayOne['w']   = date("w", strtotime(date("Y-m-d", strtotime("+$i day"))));
                $dayOne['ymd'] = date("Y-m-d", strtotime("+$i day"));
                $result[]      =  $dayOne;
            }
            $this::timeQuantum($day_interval, $time_date, $result);
        }
        $i         = 0;
        $include   = 0;
        return $result;
}

相关文章

网友评论

      本文标题:PHP 获取最近几天有效工作日的时间

      本文链接:https://www.haomeiwen.com/subject/zraplhtx.html