Units
Trait Units.
Add, subtract and set units.
Table of Contents
Methods
- add() : static
- Add given units or interval to the current instance.
- addRealUnit() : static
- addUnit() : static
- Add given units to the current instance.
- addUTCUnit() : static
- Add seconds to the instance using timestamp. Positive $value travels forward while negative $value travels into the past.
- isModifiableUnit() : bool
- Returns true if a property can be changed via setter.
- rawAdd() : static
- Call native PHP DateTime/DateTimeImmutable add() method.
- rawSub() : static
- Call native PHP DateTime/DateTimeImmutable sub() method.
- sub() : static
- Subtract given units or interval to the current instance.
- subRealUnit() : static
- subtract() : static
- Subtract given units or interval to the current instance.
- subUnit() : static
- Subtract given units to the current instance.
- subUTCUnit() : static
- Subtract seconds to the instance using timestamp. Positive $value travels into the past while negative $value travels forward.
- rawAddUnit() : static|null
Methods
add()
Add given units or interval to the current instance.
public
add(Unit|string|DateInterval|Closure|CarbonConverterInterface $unit[, int|float $value = 1 ][, bool|null $overflow = null ]) : static
Parameters
- $unit : Unit|string|DateInterval|Closure|CarbonConverterInterface
- $value : int|float = 1
- $overflow : bool|null = null
Tags
Return values
staticaddRealUnit()
public
addRealUnit(string $unit[, int|float|null $value = 1 ]) : static
Parameters
- $unit : string
- $value : int|float|null = 1
Tags
Return values
staticaddUnit()
Add given units to the current instance.
public
addUnit(Unit|string $unit[, mixed $value = 1 ][, bool|null $overflow = null ]) : static
Parameters
- $unit : Unit|string
- $value : mixed = 1
- $overflow : bool|null = null
Return values
staticaddUTCUnit()
Add seconds to the instance using timestamp. Positive $value travels forward while negative $value travels into the past.
public
addUTCUnit(string $unit[, int|float|null $value = 1 ]) : static
Parameters
- $unit : string
- $value : int|float|null = 1
Return values
staticisModifiableUnit()
Returns true if a property can be changed via setter.
public
static isModifiableUnit(string $unit) : bool
Parameters
- $unit : string
Return values
boolrawAdd()
Call native PHP DateTime/DateTimeImmutable add() method.
public
rawAdd(DateInterval $interval) : static
Parameters
- $interval : DateInterval
Return values
staticrawSub()
Call native PHP DateTime/DateTimeImmutable sub() method.
public
rawSub(DateInterval $interval) : static
Parameters
- $interval : DateInterval
Return values
staticsub()
Subtract given units or interval to the current instance.
public
sub(Unit|string|DateInterval|Closure|CarbonConverterInterface $unit[, int|float $value = 1 ][, bool|null $overflow = null ]) : static
Parameters
- $unit : Unit|string|DateInterval|Closure|CarbonConverterInterface
- $value : int|float = 1
- $overflow : bool|null = null
Tags
Return values
staticsubRealUnit()
public
subRealUnit(string $unit[, int $value = 1 ]) : static
Parameters
- $unit : string
- $value : int = 1
Tags
Return values
staticsubtract()
Subtract given units or interval to the current instance.
public
subtract(string|DateInterval $unit[, int|float $value = 1 ][, bool|null $overflow = null ]) : static
Parameters
- $unit : string|DateInterval
- $value : int|float = 1
- $overflow : bool|null = null
Tags
Return values
staticsubUnit()
Subtract given units to the current instance.
public
subUnit(Unit|string $unit[, mixed $value = 1 ][, bool|null $overflow = null ]) : static
Parameters
- $unit : Unit|string
- $value : mixed = 1
- $overflow : bool|null = null
Return values
staticsubUTCUnit()
Subtract seconds to the instance using timestamp. Positive $value travels into the past while negative $value travels forward.
public
subUTCUnit(string $unit[, int $value = 1 ]) : static
Parameters
- $unit : string
- $value : int = 1
Return values
staticrawAddUnit()
private
static rawAddUnit(self $date, string $unit, int|float $value) : static|null
Parameters
- $date : self
- $unit : string
- $value : int|float