Find dates of a perticular day between two dates in php

Suppose you want to find all modays between two dates, i mean if you want to find the all the mandays between 12-10-2017 and 29-11-2017

you can use the following function.

Declare the variables start date end date and day number.


call the function getDays


Define the function getDays

function getDays($startDate,$endDate,$dayNumber){
$endDate = strtotime($endDate);
'2' => 'Tuesday',
'3' => 'Wednesday',
'5' =>'Friday',
'6' => 'Saturday',
for($i = strtotime($days[$dayNumber], strtotime($startDate)); $i <= $endDate; $i = strtotime('+1 week', $i))

return $date_array;

Leave comment

Your email address will not be published. Required fields are marked with *.