public function DateTimePlus::diff in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Component/Datetime/DateTimePlus.php \Drupal\Component\Datetime\DateTimePlus::diff()
Returns the difference between two DateTimePlus objects.
Parameters
\Drupal\Component\Datetime\DateTimePlus|\DateTime $datetime2: The date to compare to.
bool $absolute: Should the interval be forced to be positive?
Return value
\DateInterval A DateInterval object representing the difference between the two dates.
Throws
\BadMethodCallException If the input isn't a DateTime or DateTimePlus object.
File
- core/
lib/ Drupal/ Component/ Datetime/ DateTimePlus.php, line 385
Class
- DateTimePlus
- Wraps DateTime().
Namespace
Drupal\Component\DatetimeCode
public function diff($datetime2, $absolute = FALSE) {
if ($datetime2 instanceof DateTimePlus) {
$datetime2 = $datetime2->dateTimeObject;
}
if (!$datetime2 instanceof \DateTime) {
throw new \BadMethodCallException(sprintf('Method %s expects parameter 1 to be a \\DateTime or \\Drupal\\Component\\Datetime\\DateTimePlus object', __METHOD__));
}
return $this->dateTimeObject
->diff($datetime2, $absolute);
}