$end=date_create("2013-07-30 00:30:33");
$now=date_create();
$x=date_diff($end,$now);
echo $x->format('%a days');
When I use %a it returns 45 days which is correct, when I use %d it returns 15 days. What is problem there?
$end=date_create("2013-07-30 00:30:33");
$now=date_create();
$x=date_diff($end,$now);
echo $x->format('%a days');
When I use %a it returns 45 days which is correct, when I use %d it returns 15 days. What is problem there?
Number 15 are the days calculated from difference by the months.
For example: (from http://www.php.net/manual/en/dateinterval.format.php)
<?php
$january = new DateTime('2010-01-01');
$february = new DateTime('2010-02-01');
$interval = $february->diff($january);
// %a will output the total number of days.
echo $interval->format('%a total days')."
";
// While %d will only output the number of days not already covered by the
// month.
echo $interval->format('%m month, %d days');
?>
The above example will output:
31 total days
1 month, 0 days