Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php获得今天、明天和第二天,但忽略周末_Php_Date - Fatal编程技术网

php获得今天、明天和第二天,但忽略周末

php获得今天、明天和第二天,但忽略周末,php,date,Php,Date,如何在PHP中获取当天、明天和次日,而忽略周末 我已经尝试过这个代码,但它将包括周六和周日 array( 'todayDate' => date('d/m/Y') 'tomorrowDate' => date('d/m/Y', strtotime(' +1 day')), 'nextDay' => date('l', strtotime(' +2 day')) ) 谢谢。将工作日与strotime date('l', strtotime(' +2 We

如何在PHP中获取当天、明天和次日,而忽略周末

我已经尝试过这个代码,但它将包括周六和周日

array(
    'todayDate' => date('d/m/Y')
    'tomorrowDate' => date('d/m/Y', strtotime(' +1 day')),
    'nextDay' => date('l', strtotime(' +2 day'))
)
谢谢。

工作日
strotime

date('l', strtotime(' +2 Weekdays'));

这将查找特定日期(不包括周六或周日)的下一个工作日:

当然,您也可以使用日期变量:

$myDate = '2011-04-05';
echo date('Y-m-d', strtotime($myDate . ' +2 Weekday'));

试试这个,在没有工作日的两个日期(周六和周日)之间获得日期

$startdate='10-06-2015'

$endDate='17-06-2015'

$Workingdays=getdateBettwoDate($startdate,$endDate)

打印(工作日)

函数getdateBettwoDate($startdate,$enddate) {

$myDate = '2011-04-05';
echo date('Y-m-d', strtotime($myDate . ' +2 Weekday'));
    $start    = new DateTime($startdate);
    $end      = new DateTime($enddate);
    $interval = DateInterval::createFromDateString('1 day');
    $period   = new DatePeriod($start, $interval, $end);
    $x=0;
    $a=array();      
    foreach ($period as $dt)
    {
        $temp=$dt->format("l d-m-Y");
        $ArTemp=explode(' ',$temp);
        if($ArTemp[0]=='Saturday' || $ArTemp[0]=='Sunday'){
        }else{
          $a[$x]=$ArTemp[1];
           $x++ ;
        }


    }       
    $a[$x]=date('l', strtotime( $enddate))." ".$enddate;
    return $a ;
}