Possible Duplicate:
How to calculate the difference between two dates using PHP?
$begintime=strtotime("2012-12-19");
$endtime=strtotime("2013-02-22");
The result should be;
array(
array('text'=>'12/2012','days'=>13),
array('text'=>'01/2013','days'=>31)
array('text'=>'02/2013','days'=>22)
)
For getting the days, try this:
See http://ideone.com/07wqkp
$bd->format('t')gives the maximum number of days in a month.ideone uses PHP 5.2.11. I suppose with PHP 5.4 you could use
instead of
$bd->modify("+1 month");.EDIT: Fixed bug when starting and ending in the same month and year.
EDIT:
Reverted to explicit comparisons.On second thought, it’s better without the if/else.