PHP Datediff days involved
Posted
by
user3549835
on Stack Overflow
See other posts from Stack Overflow
or by user3549835
Published on 2014-05-31T13:31:54Z
Indexed on
2014/05/31
15:26 UTC
Read the original article
Hit count: 137
I need to know how many days are involved in a date diff. \For example:
<?
$start = new DateTime('2014-06-29 14:00:00');
$ende = new DateTime('2014-07-02 05:45:00');
$diff = $start->diff($ende);
echo $diff->format('%R');
echo $diff->days;
?>
The above code echos +2
My desired result would be 4, because the 29th, 30th, 1st and 2nd of July are "touched". I have no idea to achieve that with the given functions. Coding a day-subtraction seems to bean open door for errors.
© Stack Overflow or respective owner