Php today tomorrow and the next day, but ignore the weekend

How can I get the current, tomorrow and the next day in PHP, but ignore the weekend?

I already tried this code, but it will include Saturday and Sunday.

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

Thanks.

+5
source share
3 answers

Use Weekday(s) with strtotime

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

Fiddle

+7
source

This finds the next weekday from a specific date (not including Saturday or Sunday):

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

You can also do this with a date variable:

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

Try this, enter a date between two dates without weekdays (Saturday and Sunday).

$ startdate = '10 -06-2015 ';

$ endDate = '17 -06-2015 ';

$ Workingdays = getdateBettwoDate ($ startdate, $ endDate);

print_r ($ Workers);

function 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 dmY"); $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 ; } 
0
source

All Articles