Jump to content

Display Dates between from date to date


newphpbees

Recommended Posts

Hi...

 

Good day!

 

I have table that has a field from_date and to_date.

 

Now I just want to know if how can I display as table format the dates between from_date to_date.

 

Like this

 

from_date: 2011-12-16

to_date: 2011-12-31

 

I want to display it:

 

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 // table format.

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/256982-display-dates-between-from-date-to-date/
Share on other sites

<?php
$from_date = '2011-12-16'; // get your dates from your table into php variables
$to_date = '2011-12-31';

while($from_date <= $to_date){
echo $from_date . '<br />'; // produce and output what you want here...
$from_date = date('Y-m-d',strtotime("$from_date + 1 day")); // increment the date
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.