I runned into few examples where people share code for calculating the difference between two days.
Eg.
$now = new DateTime();
$itemDate->diff($now)->format("%r%a")
But almost always these types of posts don't really have an explanation about what format parameters are about. I'm okay with regular Date format parameters but (as in this case) not sure about eg. %r.
When doing difference between DateTimeInterface
objects, DateInterval
object will be returned. You don't have DateTime's anymore, you have interval, and intervals are formatted different as DateTime objects. Format is explained here: http://php.net/manual/en/dateinterval.format.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With