(PHP 8 >= 8.6.0)
Time\Duration::negate — Returns the duration with the opposite sign
Returns a duration of the same length with the opposite sign: a positive duration becomes negative, and a negative duration becomes positive. Negating a duration of zero returns a duration of zero, which is never negative.
This function has no parameters.
Returns a new Time\Duration object.
Example #1 Time\Duration::negate() example
<?php
$duration = \Time\Duration::fromSeconds(30);
var_dump($duration->negate()->negative);
var_dump($duration->negate()->negate()->negative);
// A zero duration has no sign.
var_dump(\Time\Duration::fromSeconds(0)->negate()->negative);The above example will output:
bool(true) bool(false) bool(false)