5

Solved! i leave it here for you.

This two lines of code are ok for the 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 a given month and 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 for july --> OK

Jonathan Orrego
  • 131
  • 2
  • 6

2 Answers2

4

I hope this one will help you

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 this will help you

echo date('Y-m-d', strtotime('2016-09-01 first weekday'));
I'm Geeker
  • 4,601
  • 5
  • 22
  • 41
0

And if you dont want to use strtotime, maybe to avoid the 2038 Bug (https://www.php.net/manual/de/function.strtotime.php#refsect1-function.strtotime-notes) you can use the following code.

(new DateTime('first day of next month'))->modify('last weekday') will give you the last weekday of the actual month.

dnaumann
  • 444
  • 3
  • 13