DateTime::diffDateTimeImmutable::diffDateTimeInterface::diffdate_diffReturns the difference between two DateTime objects DescriptionObject oriented style
public DateInterval DateTime::diff
( DateTimeInterface
$datetime2
[, bool $absolute = false
] )
public DateInterval DateTimeImmutable::diff
( DateTimeInterface
$datetime2
[, bool $absolute = false
] )
public DateInterval DateTimeInterface::diff
( DateTimeInterface
$datetime2
[, bool $absolute = false
] )Procedural style
DateInterval date_diff
( DateTimeInterface
$datetime1
, DateTimeInterface $datetime2
[, bool $absolute = false
] )Returns the difference between two DateTimeInterface objects. Parameters
Return Values
The DateInterval object representing the
difference between the two dates or ExamplesExample #1 DateTime::diff example Object oriented style
<?php Procedural style
<?php The above examples will output: +2 days Example #2 DateTime object comparison
<?php The above example will output: bool(false) bool(true) bool(false) See Also
|