public DateTimePlus::diff($datetime2, $absolute = FALSE)
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 329
Class
- DateTimePlus
- Wraps DateTime().
Namespace
Drupal\Component\Datetime
Code
1 2 3 4 5 6 7 8 9 | 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 ); } |
Please login to continue.