I am developing a dynamic website where the website backend admin will select two dates (From - To) and the user in the front-end will be able to get a dropdown list between those two dates excluding weekends along with the name of the day (For e.g: <option>27th April 2015 - Monday</option>
)
I tried going by this link but in vain: Link to get date range between two dates excluding weekends.
Please Help.
The table row name for first date is skype_date_start
and for the second date is skype_date_end
.
My code as follows:
`$start = '2013/01/01'; //start date
$end = '2013/01/30'; //end date
$dates = array();
$start = $current = strtotime($start);
$end = strtotime($end);
while ($current <= $end) {
$dates[] = date('Y/m/d', $current);
$current = strtotime('+1 days', $current);
}
//now $dates hold an array of all the dates within that date range
print_r($dates);`
This only prints the array in a cluster form like :
Array ( [0] => 2013/01/01 [1] => 2013/01/02 [2] => 2013/01/03 [3] => 2013/01/04 [4] => 2013/01/05 [5] => 2013/01/06 [6] => 2013/01/07 [7] => 2013/01/08 [8] => 2013/01/09 [9] => 2013/01/10 [10] => 2013/01/11 [11] => 2013/01/12 [12] => 2013/01/13 [13] => 2013/01/14 [14] => 2013/01/15 [15] => 2013/01/16 [16] => 2013/01/17 [17] => 2013/01/18 [18] => 2013/01/19 [19] => 2013/01/20 [20] => 2013/01/21 [21] => 2013/01/22 [22] => 2013/01/23 [23] => 2013/01/24 [24] => 2013/01/25 [25] => 2013/01/26 [26] => 2013/01/27 [27] => 2013/01/28 [28] => 2013/01/29 [29] => 2013/01/30 )
.
I cannot exclude the weekends and also cannot get it to be printed as <option>27th April, 2015 - Monday</option><option>28th April 2015 - Tuesday</option>
& so on... to the last date.