2015-06-10 24 views

Trả lời

7

Sử dụng Weekday(s) với strtotime

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

Fiddle

+0

Tuyệt vời, cảm ơn bạn – V4n1ll4

2

này tìm các ngày trong tuần tiếp theo từ một ngày cụ thể (không bao gồm thứ bảy hoặc chủ nhật):

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

Bạn cũng có thể làm nó với một biến ngày của khóa học:

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

Hãy thử điều này, Nhận ngày giữa hai ngày không có ngày trong tuần (Thứ Bảy và Chủ Nhật).

$ startdate = '10 -06-2015 ';

$ endDate = '17 -06-2015 ';

$ ngày làm việc = getdateBettwoDate ($ startdate, $ endDate);

print_r ($ ngày làm việc);

chức năng getdateBettwoDate ($ STARTDATE, $ ENDDATE) {

$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 ; 
} 
Các vấn đề liên quan