Consider the following test case:
$start = new DateTime("2011-02-25");
$end = new DateTime("2011-03-25");
$interval = $end->diff($start);
echo "INTERVAL = ".$interval->format("%d");
echo "START = ".$start->format("Y-m-d");
echo "END = ".$end->format("Y-m-d");
Result:
INTERVAL = 0 <---------- WTF????
START = 2011-02-25
END = 2011-03-25
diff()seems to be claiming that the period between February 25, 2011 and March 25, 2011 is 0 days!
I have to skip something. But what?
source
share