0

My goal is to show all the days in a table selected using a two datepicker. Datepicker One for start date and date picker Two for end date. e.g 2014-08-04 to 2014-08-13.

enter image description here

As you can see at my table. It didn't include Saturday and Sunday and that is what im trying to achieved. Here is the code i've been playing around for a while:

$date1 = strtotime("2014-08-01");
$date2 = strtotime("2014-08-08");

do 
{
echo date("Y-m-d", $date1)."<br>";
$date1 = strtotime("+1 day", $date1);
} while ($date1 <= $date2);

Btw. I get the data populating my table using mysql and i want to manipulate it to show saturday and sunday using php and html.

Thanks and have a nice day!

jjydummya
  • 63
  • 2
  • 10
  • Try this link maybe this will help you http://stackoverflow.com/questions/4312439/php-return-all-dates-between-two-dates-in-an-array – Denmark Sep 02 '14 at 01:54

2 Answers2

0

So simple check day with:

date("N", $date1);

If its sat or sun there dont show it.

Daimos
  • 1,473
  • 10
  • 28
  • Thanks for your reply. I get the data populating that table using mysql and i need a php code to manipulate it to show saturday and sunday as well. – jjydummya Aug 30 '14 at 14:11
0

You could use this :

$start_date = '2014-08-01';
$start_day = date('z', strtotime($start_date));
$days_in_a_year = date('z', strtotime('2014-08-31'));

$number_of_days = ($days_in_a_year - $start_day) +1 ;
for ($i = 0; $i < $number_of_days; $i++) {
    $date = strtotime(date("Y-m-d", strtotime($start_date)) . " +$i day");
    echo date('d F - l', $date) .'<br />';
}