Eiolon Posted December 3, 2007 Share Posted December 3, 2007 I can find the number of days between two dates, however, I want the actual dates listed instead. Any examples on how to do this? Let's say I want to fnd the dates between 2007-12-01 and 2007-12-05. The output would be: 2007-12-01 2007-12-02 2007-12-03 2007-12-04 2007-12-05 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/80029-list-dates-between-two-dates/ Share on other sites More sharing options...
GingerRobot Posted December 3, 2007 Share Posted December 3, 2007 The strtotime() and date() functions are your friends here: <?php function listdates($startdate,$enddate,$format='Y-m-d'){ $date = strtotime($startdate);//convert to unix timestamp $enddate = strtotime($enddate); while($date <= $enddate){ echo date($format,$date)."<br /> \n"; $date += 60*60*24; } } listdates('2007-12-01','2007-12-05') ?> Quote Link to comment https://forums.phpfreaks.com/topic/80029-list-dates-between-two-dates/#findComment-405528 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.