diffInDays.php
Table of Contents
Functions
- diffInDays() : int
- Returns the signed number of calendar days between two instants.
Functions
diffInDays()
Returns the signed number of calendar days between two instants.
diffInDays(DateTimeInterface $a, DateTimeInterface $b) : int
DateTimeInterface::diff() is a trap for this : its DateInterval::$d is only the
day-of-month component of a y/m/d/h/i/s breakdown, which resets every
month — over a 34-day gap it reads 3, not 34. This function reads the interval's
$days instead (the true total, calendar-aware — a day that has 23 or 25 hours across
a DST transition still counts as one day) and applies $invert as the sign, so the
result is positive when $b is later than $a, negative when it is earlier.
Parameters
- $a : DateTimeInterface
-
The starting instant.
- $b : DateTimeInterface
-
The ending instant.
Tags
Return values
int —The number of calendar days from $a to $b ; negative if $b is before $a.