get the dates between two dates

date start= May 23, 2007
date end = May 22, 2008

i want to display in evey text box:

May 23, 2007
June 23, 2007
July 23, 2007
April 23, 2008

any idea? tnx n advance

date() and mktime() functions will come in handy for this…

date(“m-d-Y”, mktime(0,0,0, 5 + $i, 23, 2007);

Use a loop to loop through all the months, if you check out the date() function at You see a list of all the ways to format the date how you want it. I know the above isn’t a complete solution, but should get you going in the right direction.

ok rags tnx to you bro…

i got it dude…

<?php $mystart='April 8, 2007'; $myend='March 8, 2008'; function dateDiff($interval,$dateTimeBegin,$dateTimeEnd) { //Parse about any English textual datetime //$dateTimeBegin, $dateTimeEnd $dateTimeBegin=strtotime($dateTimeBegin); if($dateTimeBegin === -1) { return("..begin date Invalid"); } $dateTimeEnd=strtotime($dateTimeEnd); if($dateTimeEnd === -1) { return("..end date Invalid"); } $dif=$dateTimeEnd - $dateTimeBegin; switch($interval) { case "s"://seconds return($dif); case "n"://minutes return(floor($dif/60)); //60s=1m case "h"://hours return(floor($dif/3600)); //3600s=1h case "d"://days return(floor($dif/86400)); //86400s=1d case "ww"://Week return(floor($dif/604800)); //604800s=1week=1semana case "m": //similar result "m" dateDiff Microsoft $monthBegin=(date("Y",$dateTimeBegin)*12)+ date("n",$dateTimeBegin); $monthEnd=(date("Y",$dateTimeEnd)*12)+ date("n",$dateTimeEnd); $monthDiff=$monthEnd-$monthBegin; return($monthDiff); case "yyyy": //similar result "yyyy" dateDiff Microsoft return(date("Y",$dateTimeEnd) - date("Y",$dateTimeBegin)); default: return(floor($dif/86400)); //86400s=1d } } $xx = dateDiff("m",$mystart,$myend); // add +1 to add 1 month for($ii=0;$ii<=$xx;$ii++) { $mydates.=' '.date("F d, Y",strtotime($mystart." +$ii month")).' '.$nwcamount.' '; } ?> <? echo $mydates; ?>
Sponsor our Newsletter | Privacy Policy | Terms of Service