TeddyKiller Posted April 14, 2010 Share Posted April 14, 2010 $date1 = '2010-6-6'; $date2 = '2010-6-2'; I'm wanting to display a tiny calendar beween these two dates, including the same date (Days) For example. Jan ---- feb ----- 29 30 31 1 2 3 4 5 How is this possible..? Link to comment https://forums.phpfreaks.com/topic/198501-displaying-a-time-line-of-2-dates/ Share on other sites More sharing options...
aeroswat Posted April 14, 2010 Share Posted April 14, 2010 Found a function of a way to get your dates in an array function createDateRangeArray($strDateFrom,$strDateTo) { // takes two dates formatted as YYYY-MM-DD and creates an // inclusive array of the dates between the from and to dates. // could test validity of dates here but I'm already doing // that in the main script $aryRange=array(); $iDateFrom=mktime(1,0,0,substr($strDateFrom,5,2), substr($strDateFrom,8,2),substr($strDateFrom,0,4)); $iDateTo=mktime(1,0,0,substr($strDateTo,5,2), substr($strDateTo,8,2),substr($strDateTo,0,4)); if ($iDateTo>=$iDateFrom) { array_push($aryRange,date('Y-m-d',$iDateFrom)); // first entry while ($iDateFrom<$iDateTo) { $iDateFrom+=86400; // add 24 hours array_push($aryRange,date('Y-m-d',$iDateFrom)); } } return $aryRange; } And then you would only need figure out what day the starting date was on with something like this date('l', strtotime($date)); and loop to make the display of your calendar Link to comment https://forums.phpfreaks.com/topic/198501-displaying-a-time-line-of-2-dates/#findComment-1041607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.