jeeva Posted January 20, 2007 Share Posted January 20, 2007 hi Frnds,how can i get date difference between two dates for example if i have selected 29-12-2006 and 05-01-2007 then i want display the dates like 30-12-2007,31-12-2007,01-01-2007,02-01-2007,03-01-2007 and 04-01-2007.thanks in advancejeeva.. Link to comment https://forums.phpfreaks.com/topic/34969-date-difference/ Share on other sites More sharing options...
paul2463 Posted January 20, 2007 Share Posted January 20, 2007 try this[code]<?php$start = "20-2-2007";$end = "3-3-2007";$st = explode("-",$start);$newStart = strtotime("$st[2]-$st[1]-$st[0]"); //rearange date so it is Y-m-d/coverts to timestamp$fi = explode("-",$end);$newEnd = strtotime("$fi[2]-$fi[1]-$fi[0]");do{ echo date("d-m-Y",$newStart); echo ", "; $newStart = strtotime("+1 day", $newStart); }while ($newStart < $newEnd)?>[/code]it prints out all the dates from the start date to the end date Link to comment https://forums.phpfreaks.com/topic/34969-date-difference/#findComment-164932 Share on other sites More sharing options...
jeeva Posted January 20, 2007 Author Share Posted January 20, 2007 thanks a lot...it saved me Link to comment https://forums.phpfreaks.com/topic/34969-date-difference/#findComment-164934 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.