php first and last weekday (workable Mon-Fri) of month using simple strtotime -


solved! leave here you.

this 2 lines of code ok first workable day:

date('d-m-y',strtotime('+0 weekdays october 2016')) 

returns : 3-10-2016 --> ok

date('d-m-y', strtotime('weekday february 2016')) 

returns : 1-2-2016 --> ok

the last workable day of given month , year:

$year=2016; $month='october'; $lastworkable=date('d-m-y', strtotime('last weekday '.date("f y", strtotime('next month '.$month.' '.$year)))); 

returns : 29-07-2016 july --> ok

i hope 1

edit 1

  <?php echo date('d-m-y',strtotime("last monday of july 2016")); //25-07-2016    echo date('d-m-y',strtotime("last monday of october 2016")); //31-10-2016 

edit 2

sure you

echo date('y-m-d', strtotime('2016-09-01 first weekday')); 

Comments