CarbonInterval
extends DateInterval
in package
implements
CarbonConverterInterface
Uses
LocalFactory, IntervalRounding, IntervalStep, MagicParameter, Mixin, Options, ToStringFormat
A simple API extension for DateInterval.
The implementation provides helpers to handle weeks but only days are saved. Weeks are calculated based on the total days of the current instance.
Table of Contents
Interfaces
Constants
- NEGATIVE = -1
- NO_LIMIT = -1
- Unlimited parts for forHumans() method.
- PERIOD_DAYS = 'D'
- PERIOD_HOURS = 'H'
- PERIOD_MINUTES = 'M'
- PERIOD_MONTHS = 'M'
- PERIOD_PREFIX = 'P'
- Interval spec period designators
- PERIOD_SECONDS = 'S'
- PERIOD_TIME_PREFIX = 'T'
- PERIOD_YEARS = 'Y'
- POSITIVE = 1
- SPECIAL_TRANSLATIONS = [1 => ['option' => \Carbon\CarbonInterface::ONE_DAY_WORDS, 'future' => 'diff_tomorrow', 'past' => 'diff_yesterday'], 2 => ['option' => \Carbon\CarbonInterface::TWO_DAY_WORDS, 'future' => 'diff_after_tomorrow', 'past' => 'diff_before_yesterday']]
Properties
- $daysExcludeWeeks : int
- $dayz : int
- $dayzExcludeWeeks : int
- $hours : int
- $locale : string
- $microExcludeMilli : int
- $microseconds : int
- $milliseconds : int
- $minutes : int
- $months : int
- $seconds : int
- $totalDays : float
- $totalDayz : float
- $totalHours : float
- $totalMicroseconds : float
- $totalMilliseconds : float
- $totalMinutes : float
- $totalMonths : float
- $totalSeconds : float
- $totalWeeks : float
- $totalYears : float
- $weeks : int
- $years : int
- $cascadeFactors : array<string|int, mixed>|null
- $endDate : CarbonInterface|null
- End date if interval was created from a difference between 2 dates.
- $formats : array<string|int, mixed>
- $initialValues : array<string|int, mixed>|null
- $localFormatFunction : string|callable|null
- Function to call instead of format.
- $localGenericMacros : array<string|int, mixed>|null
- Instance-specific generic macros.
- $localHumanDiffOptions : int|null
- Options for diffForHumans and forHumans methods.
- $localMacros : array<string|int, mixed>|null
- Instance-specific macros.
- $localMonthsOverflow : bool|null
- Indicates if months should be calculated with overflow.
- $localSerializer : string|callable|null
- Format to use on JSON serialization.
- $localStrictModeEnabled : bool|null
- Indicates if the strict mode is in use.
- $localToStringFormat : string|callable|null
- Format to use on string cast.
- $localYearsOverflow : bool|null
- Indicates if years should be calculated with overflow.
- $macroContextStack : array<string|int, mixed>
- Stack of macro instance contexts.
- $macros : array<string|int, mixed>
- The registered macros.
- $originalInput : mixed
- The input used to create the interval.
- $rawInterval : DateInterval|null
- End date if interval was created from a difference between 2 dates.
- $startDate : CarbonInterface|null
- Start date if interval was created from a difference between 2 dates.
- $step : Closure|null
- Step to apply instead of a fixed interval to get the new date.
- $timezoneSetting : DateTimeZone|string|int|null
- Timezone handler for settings() method.
- $clock : WrapperClock|null
- The clock that generated the current instance (or FactoryImmutable::getDefaultInstance() if none)
- $flipCascadeFactors : array<string|int, mixed>|null
- $floatSettersEnabled : bool
Methods
- __call() : static|int|float|string
- Allow fluent calls on the setters... CarbonInterval::years(3)->months(5)->day().
- __callStatic() : static|mixed|null
- Provide static helpers to create instances. Allows CarbonInterval::years(3).
- __construct() : mixed
- Create a new CarbonInterval instance.
- __debugInfo() : array<string|int, mixed>
- Show truthy properties on var_dump().
- __get() : int|float|string|null
- Get a part of the CarbonInterval object.
- __set() : mixed
- Set a part of the CarbonInterval object.
- __set_state() : static
- Evaluate the PHP generated by var_export() and recreate the exported CarbonInterval instance.
- __toString() : string
- Format the instance as a string using the forHumans() function.
- __unserialize() : void
- abs() : $this
- Invert the interval if it's inverted.
- absolute() : $this
- add() : $this
- Add the passed interval to the current instance.
- addDays() : $this
- addHours() : $this
- addMicroseconds() : $this
- addMilliseconds() : $this
- addMinutes() : $this
- addMonths() : $this
- addSeconds() : $this
- addWeeks() : $this
- addYears() : $this
- between() : bool
- Determines if the instance is between two others.
- betweenExcluded() : bool
- Determines if the instance is between two others, bounds excluded.
- betweenIncluded() : bool
- Determines if the instance is between two others, bounds excluded.
- cascade() : $this
- Convert overflowed values into bigger units.
- cast() : T
- Cast the current instance into the given class.
- ceil() : $this
- Ceil the current instance second with given precision if specified.
- ceilCenturies() : $this
- ceilCentury() : $this
- ceilDay() : $this
- ceilDays() : $this
- ceilDecade() : $this
- ceilDecades() : $this
- ceilHour() : $this
- ceilHours() : $this
- ceilMicrosecond() : $this
- ceilMicroseconds() : $this
- ceilMillennia() : $this
- ceilMillennium() : $this
- ceilMillisecond() : $this
- ceilMilliseconds() : $this
- ceilMinute() : $this
- ceilMinutes() : $this
- ceilMonth() : $this
- ceilMonths() : $this
- ceilQuarter() : $this
- ceilQuarters() : $this
- ceilSecond() : $this
- ceilSeconds() : $this
- ceilUnit() : $this
- Ceil the current instance at the given unit with given precision if specified.
- ceilWeek() : $this
- ceilWeeks() : $this
- ceilYear() : $this
- ceilYears() : $this
- clone() : static
- Get a copy of the instance.
- compare() : int
- Comparing with passed interval.
- compareDateIntervals() : int
- Comparing 2 date intervals.
- convertDate() : CarbonInterface
- Take a date and apply either the step if set, or the current interval else.
- copy() : static
- Get a copy of the instance.
- create() : static
- Create a new CarbonInterval instance from specific values.
- createFromDateString() : static
- Sets up a DateInterval from the relative parts of the string.
- createFromFormat() : static
- Parse a string into a new CarbonInterval object according to the specified format.
- day() : CarbonInterval
- days() : CarbonInterval
- daysExcludeWeeks() : CarbonInterval
- dayz() : CarbonInterval
- dayzExcludeWeeks() : CarbonInterval
- diff() : static
- Create an interval from the difference between 2 dates.
- divide() : $this
- Divide and cascade current instance by a given divider.
- enableFloatSetters() : void
- This option allow you to opt-in for the Carbon 3 behavior where float values will no longer be cast to integer (so truncated).
- end() : CarbonInterface|null
- Return the end date if interval was created from a difference between 2 dates.
- eq() : bool
- Determines if the instance is equal to another
- equalTo() : bool
- Determines if the instance is equal to another
- floor() : $this
- Round the current instance second with given precision if specified.
- floorCenturies() : $this
- floorCentury() : $this
- floorDay() : $this
- floorDays() : $this
- floorDecade() : $this
- floorDecades() : $this
- floorHour() : $this
- floorHours() : $this
- floorMicrosecond() : $this
- floorMicroseconds() : $this
- floorMillennia() : $this
- floorMillennium() : $this
- floorMillisecond() : $this
- floorMilliseconds() : $this
- floorMinute() : $this
- floorMinutes() : $this
- floorMonth() : $this
- floorMonths() : $this
- floorQuarter() : $this
- floorQuarters() : $this
- floorSecond() : $this
- floorSeconds() : $this
- floorUnit() : $this
- Truncate the current instance at the given unit with given precision if specified.
- floorWeek() : $this
- floorWeeks() : $this
- floorYear() : $this
- floorYears() : $this
- forHumans() : string
- Get the current interval in a human readable format in the current locale.
- format() : string
- fromString() : static
- Creates a CarbonInterval from string.
- get() : int|float|string|null
- Get a part of the CarbonInterval object.
- getCascadeFactors() : array<string|int, mixed>
- Mapping of units and factors for cascading.
- getClock() : WrapperClock|null
- getDateIntervalSpec() : string
- Get the interval_spec string of a date interval.
- getDaysPerWeek() : int|float
- Returns current config for days per week.
- getFactor() : int|float|null
- Returns the factor for a given source-to-target couple.
- getFactorWithDefault() : int|float|null
- Returns the factor for a given source-to-target couple if set, else try to find the appropriate constant as the factor, such as Carbon::DAYS_PER_WEEK.
- getHoursPerDay() : int|float
- Returns current config for hours per day.
- getMicrosecondsPerMillisecond() : int|float
- Returns current config for microseconds per second.
- getMillisecondsPerSecond() : int|float
- Returns current config for microseconds per second.
- getMinutesPerHour() : int|float
- Returns current config for minutes per hour.
- getNonZeroValues() : array<string|int, int>
- Returns interval non-zero values as an array where key are the unit names and values the counts.
- getSecondsPerMinute() : int|float
- Returns current config for seconds per minute.
- getSettings() : array<string|int, mixed>
- Returns current local settings.
- getStep() : Closure
- Get the dynamic step in use.
- getValuesSequence() : array<string|int, int>
- Returns interval values as an array where key are the unit names and values the counts from the biggest non-zero one the the smallest non-zero one.
- greaterThan() : bool
- Determines if the instance is greater (longer) than another
- greaterThanOrEqualTo() : bool
- Determines if the instance is greater (longer) than or equal to another
- gt() : bool
- Determines if the instance is greater (longer) than another
- gte() : bool
- Determines if the instance is greater (longer) than or equal to another
- hasMacro() : bool
- Check if macro is registered.
- hasNegativeValues() : bool
- hasPositiveValues() : bool
- hour() : CarbonInterval
- hours() : CarbonInterval
- instance() : static
- Create a CarbonInterval instance from a DateInterval one. Can not instance DateInterval objects created from DateTime::diff() as you can't externally set the $days field.
- invert() : $this
- Invert the interval.
- isBetween() : bool
- Determines if the instance is between two others
- isEmpty() : bool
- Returns true if the interval is empty for each unit.
- lessThan() : bool
- Determines if the instance is less (shorter) than another
- lessThanOrEqualTo() : bool
- Determines if the instance is less (shorter) than or equal to another
- lt() : bool
- Determines if the instance is less (shorter) than another
- lte() : bool
- Determines if the instance is less (shorter) than or equal to another
- macro() : void
- Register a custom macro.
- make() : static|null
- Make a CarbonInterval instance from given variable if possible.
- microsecond() : CarbonInterval
- microseconds() : CarbonInterval
- millisecond() : CarbonInterval
- milliseconds() : CarbonInterval
- minus() : $this
- Add given parameters to the current interval.
- minute() : CarbonInterval
- minutes() : CarbonInterval
- mixin() : void
- Register macros from a mixin object.
- month() : CarbonInterval
- months() : CarbonInterval
- multiply() : $this
- Multiply and cascade current instance by a given factor.
- ne() : bool
- Determines if the instance is not equal to another
- notEqualTo() : bool
- Determines if the instance is not equal to another
- optimize() : $this
- Get rid of the original input, start date and end date that may be kept in memory.
- original() : array<string|int, mixed>|int|string|DateInterval|mixed|null
- Return the original source used to create the current interval.
- parseFromLocale() : static
- Creates a CarbonInterval from string using a different locale.
- plus() : $this
- Add given parameters to the current interval.
- resetToStringFormat() : void
- Reset the format used to the default when type juggling a Carbon instance to a string
- round() : $this
- Round the current instance second with given precision if specified.
- roundCenturies() : $this
- roundCentury() : $this
- roundDay() : $this
- roundDays() : $this
- roundDecade() : $this
- roundDecades() : $this
- roundHour() : $this
- roundHours() : $this
- roundMicrosecond() : $this
- roundMicroseconds() : $this
- roundMillennia() : $this
- roundMillennium() : $this
- roundMillisecond() : $this
- roundMilliseconds() : $this
- roundMinute() : $this
- roundMinutes() : $this
- roundMonth() : $this
- roundMonths() : $this
- roundQuarter() : $this
- roundQuarters() : $this
- roundSecond() : $this
- roundSeconds() : $this
- roundUnit() : static
- Round the current instance at the given unit with given precision if specified and the given function.
- roundWeek() : $this
- roundWeeks() : $this
- roundYear() : $this
- roundYears() : $this
- second() : CarbonInterval
- seconds() : CarbonInterval
- set() : $this
- Set a part of the CarbonInterval object.
- setCascadeFactors() : mixed
- Set default cascading factors for ->cascade() method.
- setStep() : void
- Set a step to apply instead of a fixed interval to get the new date.
- setTimezone() : static
- Set the instance's timezone from a string or object.
- settings() : $this|static
- Set specific options.
- setToStringFormat() : void
- shares() : $this
- Divide current instance by a given divider. shares() is naive, it divides each unit separately and the result is rounded for each unit. So 5 hours and 20 minutes shared by 3 becomes 2 hours and 7 minutes.
- shiftTimezone() : static
- Set the instance's timezone from a string or object and add/subtract the offset difference.
- spec() : string
- Get the interval_spec string.
- start() : CarbonInterface|null
- Return the start date if interval was created from a difference between 2 dates.
- stepBy() : CarbonPeriod
- Decompose the current interval into
- sub() : $this
- Subtract the passed interval to the current instance.
- subDays() : $this
- subHours() : $this
- subMicroseconds() : $this
- subMilliseconds() : $this
- subMinutes() : $this
- subMonths() : $this
- subSeconds() : $this
- subtract() : $this
- Subtract the passed interval to the current instance.
- subWeeks() : $this
- subYears() : $this
- times() : $this
- Multiply current instance given number of times. times() is naive, it multiplies each unit (so day can be greater than 31, hour can be greater than 23, etc.) and the result is rounded separately for each unit.
- toArray() : array<string|int, int>
- Returns interval values as an array where key are the unit names and values the counts.
- toDateInterval() : DateInterval
- Return native DateInterval PHP object matching the current instance.
- toPeriod() : CarbonPeriod
- Convert the interval to a CarbonPeriod.
- total() : float
- Get amount of given unit equivalent to the interval.
- week() : CarbonInterval
- weeks() : CarbonInterval
- weeksAndDays() : static
- Allow setting of weeks and days to be cumulative.
- year() : CarbonInterval
- years() : CarbonInterval
- addExtraDebugInfos() : void
- bindMacroContext() : mixed
- Stack a Carbon context from inside calls of self::this() and execute a given action.
- callMacro() : mixed
- Call given macro.
- callRoundMethod() : static|null
- context() : static|null
- Return the current context from inside a macro callee or a null if static.
- copyProperties() : static
- getDefaultCascadeFactors() : array<string|int, mixed>
- getForHumansInitialVariables() : array<string|int, mixed>
- getForHumansParameters() : array<string|int, mixed>
- getRoundingMethodFromOptions() : string|null
- isLocalStrictModeEnabled() : bool
- makeFromString() : self|null
- resolveInterval() : self|null
- roundWith() : static|null
- solveNegativeInterval() : static
- this() : static
- Return the current context from inside a macro callee or a new one if static.
- assertSafeForInteger() : void
- Throw an exception if precision loss when storing the given value as an integer would be >= 1.0.
- castIntervalToClass() : T
- checkIntegerValue() : void
- checkStartAndEnd() : void
- copyNegativeUnits() : void
- copyStep() : void
- doCascade() : static
- getAnonymousClassCodeForTrait() : string
- getFactory() : Factory
- getFlipCascadeFactors() : array<string|int, mixed>
- getInnerValues() : array<string|int, mixed>
- getMagicParameter() : mixed
- getMixableMethods() : Generator
- handleDecimalPart() : void
- initLocalFactory() : void
- invertCascade() : static
- loadMixinClass() : void
- loadMixinTrait() : void
- needsDeclension() : bool
- resolveCarbon() : Carbon|CarbonImmutable
- Convert DateTimeImmutable instance to CarbonImmutable instance and DateTime instance to Carbon instance.
- setSetting() : $this
- standardizeUnit() : string
- transmitFactory() : T
- Trigger the given action using the local factory of the object, so it will be transmitted to any object also using this trait and calling initLocalFactory() in its constructor.
- withOriginal() : T
Constants
NEGATIVE
public
mixed
NEGATIVE
= -1
NO_LIMIT
Unlimited parts for forHumans() method.
public
mixed
NO_LIMIT
= -1
INF constant can be used instead.
PERIOD_DAYS
public
mixed
PERIOD_DAYS
= 'D'
PERIOD_HOURS
public
mixed
PERIOD_HOURS
= 'H'
PERIOD_MINUTES
public
mixed
PERIOD_MINUTES
= 'M'
PERIOD_MONTHS
public
mixed
PERIOD_MONTHS
= 'M'
PERIOD_PREFIX
Interval spec period designators
public
mixed
PERIOD_PREFIX
= 'P'
PERIOD_SECONDS
public
mixed
PERIOD_SECONDS
= 'S'
PERIOD_TIME_PREFIX
public
mixed
PERIOD_TIME_PREFIX
= 'T'
PERIOD_YEARS
public
mixed
PERIOD_YEARS
= 'Y'
POSITIVE
public
mixed
POSITIVE
= 1
SPECIAL_TRANSLATIONS
public
mixed
SPECIAL_TRANSLATIONS
= [1 => ['option' => \Carbon\CarbonInterface::ONE_DAY_WORDS, 'future' => 'diff_tomorrow', 'past' => 'diff_yesterday'], 2 => ['option' => \Carbon\CarbonInterface::TWO_DAY_WORDS, 'future' => 'diff_after_tomorrow', 'past' => 'diff_before_yesterday']]
Properties
$daysExcludeWeeks
public
int
$daysExcludeWeeks
alias of dayzExcludeWeeks
$dayz
public
int
$dayz
Total days of the current interval (weeks * 7 + days).
$dayzExcludeWeeks
public
int
$dayzExcludeWeeks
Total days remaining in the final week of the current instance (days % 7).
$hours
public
int
$hours
Total hours of the current interval.
$locale read-only
public
string
$locale
locale of the current instance
$microExcludeMilli
public
int
$microExcludeMilli
Remaining microseconds without the milliseconds.
$microseconds
public
int
$microseconds
Total microseconds of the current interval.
$milliseconds
public
int
$milliseconds
Total milliseconds of the current interval.
$minutes
public
int
$minutes
Total minutes of the current interval.
$months
public
int
$months
Total months of the current interval.
$seconds
public
int
$seconds
Total seconds of the current interval.
$totalDays read-only
public
float
$totalDays
Number of days equivalent to the interval.
$totalDayz read-only
public
float
$totalDayz
Alias for totalDays.
$totalHours read-only
public
float
$totalHours
Number of hours equivalent to the interval.
$totalMicroseconds read-only
public
float
$totalMicroseconds
Number of microseconds equivalent to the interval.
$totalMilliseconds read-only
public
float
$totalMilliseconds
Number of milliseconds equivalent to the interval.
$totalMinutes read-only
public
float
$totalMinutes
Number of minutes equivalent to the interval.
$totalMonths read-only
public
float
$totalMonths
Number of months equivalent to the interval.
$totalSeconds read-only
public
float
$totalSeconds
Number of seconds equivalent to the interval.
$totalWeeks read-only
public
float
$totalWeeks
Number of weeks equivalent to the interval.
$totalYears read-only
public
float
$totalYears
Number of years equivalent to the interval.
$weeks
public
int
$weeks
Total weeks of the current interval calculated from the days.
$years
public
int
$years
Total years of the current interval.
$cascadeFactors
protected
static array<string|int, mixed>|null
$cascadeFactors
= null
$endDate
End date if interval was created from a difference between 2 dates.
protected
CarbonInterface|null
$endDate
= null
$formats
protected
static array<string|int, mixed>
$formats
= ['y' => 'y', 'Y' => 'y', 'o' => 'y', 'm' => 'm', 'n' => 'm', 'W' => 'weeks', 'd' => 'd', 'j' => 'd', 'z' => 'd', 'h' => 'h', 'g' => 'h', 'H' => 'h', 'G' => 'h', 'i' => 'i', 's' => 's', 'u' => 'micro', 'v' => 'milli']
$initialValues
protected
array<string|int, mixed>|null
$initialValues
= null
$localFormatFunction
Function to call instead of format.
protected
string|callable|null
$localFormatFunction
= null
$localGenericMacros
Instance-specific generic macros.
protected
array<string|int, mixed>|null
$localGenericMacros
= null
$localHumanDiffOptions
Options for diffForHumans and forHumans methods.
protected
int|null
$localHumanDiffOptions
= null
$localMacros
Instance-specific macros.
protected
array<string|int, mixed>|null
$localMacros
= null
$localMonthsOverflow
Indicates if months should be calculated with overflow.
protected
bool|null
$localMonthsOverflow
= null
Specific setting.
$localSerializer
Format to use on JSON serialization.
protected
string|callable|null
$localSerializer
= null
$localStrictModeEnabled
Indicates if the strict mode is in use.
protected
bool|null
$localStrictModeEnabled
= null
Specific setting.
$localToStringFormat
Format to use on string cast.
protected
string|callable|null
$localToStringFormat
= null
$localYearsOverflow
Indicates if years should be calculated with overflow.
protected
bool|null
$localYearsOverflow
= null
Specific setting.
$macroContextStack
Stack of macro instance contexts.
protected
static array<string|int, mixed>
$macroContextStack
= []
$macros
The registered macros.
protected
static array<string|int, mixed>
$macros
= []
$originalInput
The input used to create the interval.
protected
mixed
$originalInput
= null
$rawInterval
End date if interval was created from a difference between 2 dates.
protected
DateInterval|null
$rawInterval
= null
$startDate
Start date if interval was created from a difference between 2 dates.
protected
CarbonInterface|null
$startDate
= null
$step
Step to apply instead of a fixed interval to get the new date.
protected
Closure|null
$step
$timezoneSetting
Timezone handler for settings() method.
protected
DateTimeZone|string|int|null
$timezoneSetting
= null
$clock
The clock that generated the current instance (or FactoryImmutable::getDefaultInstance() if none)
private
WrapperClock|null
$clock
= null
$flipCascadeFactors
private
static array<string|int, mixed>|null
$flipCascadeFactors
= null
$floatSettersEnabled
private
static bool
$floatSettersEnabled
= false
Methods
__call()
Allow fluent calls on the setters... CarbonInterval::years(3)->months(5)->day().
public
__call(string $method, array<string|int, mixed> $parameters) : static|int|float|string
Note: This is done using the magic method to allow static and instance methods to have the same names.
Parameters
- $method : string
-
magic method name called
- $parameters : array<string|int, mixed>
-
parameters list
Tags
Return values
static|int|float|string__callStatic()
Provide static helpers to create instances. Allows CarbonInterval::years(3).
public
static __callStatic(string $method, array<string|int, mixed> $parameters) : static|mixed|null
Note: This is done using the magic method to allow static and instance methods to have the same names.
Parameters
- $method : string
-
magic method name called
- $parameters : array<string|int, mixed>
-
parameters list
Return values
static|mixed|null__construct()
Create a new CarbonInterval instance.
public
__construct([Closure|DateInterval|string|int|null $years = null ][, int|float|null $months = null ][, int|float|null $weeks = null ][, int|float|null $days = null ][, int|float|null $hours = null ][, int|float|null $minutes = null ][, int|float|null $seconds = null ][, int|float|null $microseconds = null ]) : mixed
Parameters
- $years : Closure|DateInterval|string|int|null = null
- $months : int|float|null = null
- $weeks : int|float|null = null
- $days : int|float|null = null
- $hours : int|float|null = null
- $minutes : int|float|null = null
- $seconds : int|float|null = null
- $microseconds : int|float|null = null
Tags
__debugInfo()
Show truthy properties on var_dump().
public
__debugInfo() : array<string|int, mixed>
Return values
array<string|int, mixed>__get()
Get a part of the CarbonInterval object.
public
__get(string $name) : int|float|string|null
Parameters
- $name : string
Return values
int|float|string|null__set()
Set a part of the CarbonInterval object.
public
__set(string $name, int $value) : mixed
Parameters
- $name : string
- $value : int
Tags
__set_state()
Evaluate the PHP generated by var_export() and recreate the exported CarbonInterval instance.
public
static __set_state(array<string|int, mixed> $dump) : static
Parameters
- $dump : array<string|int, mixed>
-
data as exported by var_export()
Return values
static__toString()
Format the instance as a string using the forHumans() function.
public
__toString() : string
Tags
Return values
string__unserialize()
public
__unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
abs()
Invert the interval if it's inverted.
public
abs([bool $absolute = false ]) : $this
Parameters
- $absolute : bool = false
-
do nothing if set to false
Return values
$thisabsolute()
public
absolute([bool $absolute = true ]) : $this
Parameters
- $absolute : bool = true
-
do nothing if set to false
Tags
Return values
$thisadd()
Add the passed interval to the current instance.
public
add(string|DateInterval $unit[, int|float $value = 1 ]) : $this
Parameters
- $unit : string|DateInterval
- $value : int|float = 1
Return values
$thisaddDays()
public
addDays(int|float $days) : $this
Add given number of days to the current interval
Parameters
- $days : int|float
Return values
$thisaddHours()
public
addHours(int|float $hours) : $this
Add given number of hours to the current interval
Parameters
- $hours : int|float
Return values
$thisaddMicroseconds()
public
addMicroseconds(int|float $microseconds) : $this
Add given number of microseconds to the current interval
Parameters
- $microseconds : int|float
Return values
$thisaddMilliseconds()
public
addMilliseconds(int|float $milliseconds) : $this
Add given number of milliseconds to the current interval
Parameters
- $milliseconds : int|float
Return values
$thisaddMinutes()
public
addMinutes(int|float $minutes) : $this
Add given number of minutes to the current interval
Parameters
- $minutes : int|float
Return values
$thisaddMonths()
public
addMonths(int $months) : $this
Add given number of months to the current interval
Parameters
- $months : int
Return values
$thisaddSeconds()
public
addSeconds(int|float $seconds) : $this
Add given number of seconds to the current interval
Parameters
- $seconds : int|float
Return values
$thisaddWeeks()
public
addWeeks(int|float $weeks) : $this
Add given number of weeks to the current interval
Parameters
- $weeks : int|float
Return values
$thisaddYears()
public
addYears(int $years) : $this
Add given number of years to the current interval
Parameters
- $years : int
Return values
$thisbetween()
Determines if the instance is between two others.
public
between(CarbonInterval|DateInterval|mixed $interval1, CarbonInterval|DateInterval|mixed $interval2[, bool $equal = true ]) : bool
The third argument allow you to specify if bounds are included or not (true by default) but for when you including/excluding bounds may produce different results in your application, we recommend to use the explicit methods ->betweenIncluded() or ->betweenExcluded() instead.
Parameters
- $interval1 : CarbonInterval|DateInterval|mixed
- $interval2 : CarbonInterval|DateInterval|mixed
- $equal : bool = true
-
Indicates if an equal to comparison should be done
Tags
Return values
boolbetweenExcluded()
Determines if the instance is between two others, bounds excluded.
public
betweenExcluded(CarbonInterval|DateInterval|mixed $interval1, CarbonInterval|DateInterval|mixed $interval2) : bool
Parameters
- $interval1 : CarbonInterval|DateInterval|mixed
- $interval2 : CarbonInterval|DateInterval|mixed
Tags
Return values
boolbetweenIncluded()
Determines if the instance is between two others, bounds excluded.
public
betweenIncluded(CarbonInterval|DateInterval|mixed $interval1, CarbonInterval|DateInterval|mixed $interval2) : bool
Parameters
- $interval1 : CarbonInterval|DateInterval|mixed
- $interval2 : CarbonInterval|DateInterval|mixed
Tags
Return values
boolcascade()
Convert overflowed values into bigger units.
public
cascade() : $this
Return values
$thiscast()
Cast the current instance into the given class.
public
cast(string $className) : T
Parameters
- $className : string
Tags
Return values
Tceil()
Ceil the current instance second with given precision if specified.
public
ceil([DateInterval|string|float|int $precision = 1 ]) : $this
Parameters
- $precision : DateInterval|string|float|int = 1
Tags
Return values
$thisceilCenturies()
public
ceilCenturies(int|float $precision = 1) : $this
Ceil the current instance century with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilCentury()
public
ceilCentury(int|float $precision = 1) : $this
Ceil the current instance century with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilDay()
public
ceilDay(int|float $precision = 1) : $this
Ceil the current instance day with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilDays()
public
ceilDays(int|float $precision = 1) : $this
Ceil the current instance day with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilDecade()
public
ceilDecade(int|float $precision = 1) : $this
Ceil the current instance decade with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilDecades()
public
ceilDecades(int|float $precision = 1) : $this
Ceil the current instance decade with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilHour()
public
ceilHour(int|float $precision = 1) : $this
Ceil the current instance hour with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilHours()
public
ceilHours(int|float $precision = 1) : $this
Ceil the current instance hour with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilMicrosecond()
public
ceilMicrosecond(int|float $precision = 1) : $this
Ceil the current instance microsecond with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilMicroseconds()
public
ceilMicroseconds(int|float $precision = 1) : $this
Ceil the current instance microsecond with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilMillennia()
public
ceilMillennia(int|float $precision = 1) : $this
Ceil the current instance millennium with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilMillennium()
public
ceilMillennium(int|float $precision = 1) : $this
Ceil the current instance millennium with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilMillisecond()
public
ceilMillisecond(int|float $precision = 1) : $this
Ceil the current instance millisecond with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilMilliseconds()
public
ceilMilliseconds(int|float $precision = 1) : $this
Ceil the current instance millisecond with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilMinute()
public
ceilMinute(int|float $precision = 1) : $this
Ceil the current instance minute with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilMinutes()
public
ceilMinutes(int|float $precision = 1) : $this
Ceil the current instance minute with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilMonth()
public
ceilMonth(int|float $precision = 1) : $this
Ceil the current instance month with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilMonths()
public
ceilMonths(int|float $precision = 1) : $this
Ceil the current instance month with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilQuarter()
public
ceilQuarter(int|float $precision = 1) : $this
Ceil the current instance quarter with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilQuarters()
public
ceilQuarters(int|float $precision = 1) : $this
Ceil the current instance quarter with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilSecond()
public
ceilSecond(int|float $precision = 1) : $this
Ceil the current instance second with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilSeconds()
public
ceilSeconds(int|float $precision = 1) : $this
Ceil the current instance second with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilUnit()
Ceil the current instance at the given unit with given precision if specified.
public
ceilUnit(string $unit[, float|int|string|DateInterval|null $precision = 1 ]) : $this
Parameters
- $unit : string
- $precision : float|int|string|DateInterval|null = 1
Tags
Return values
$thisceilWeek()
public
ceilWeek(int|float $precision = 1) : $this
Ceil the current instance day with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilWeeks()
public
ceilWeeks(int|float $precision = 1) : $this
Ceil the current instance day with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilYear()
public
ceilYear(int|float $precision = 1) : $this
Ceil the current instance year with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisceilYears()
public
ceilYears(int|float $precision = 1) : $this
Ceil the current instance year with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisclone()
Get a copy of the instance.
public
clone() : static
Return values
staticcompare()
Comparing with passed interval.
public
compare(DateInterval $interval) : int
Parameters
- $interval : DateInterval
Return values
int —0, 1 or -1
compareDateIntervals()
Comparing 2 date intervals.
public
static compareDateIntervals(DateInterval $first, DateInterval $second) : int
Parameters
- $first : DateInterval
- $second : DateInterval
Return values
int —0, 1 or -1
convertDate()
Take a date and apply either the step if set, or the current interval else.
public
convertDate(DateTimeInterface $dateTime[, bool $negated = false ]) : CarbonInterface
The interval/step is applied negatively (typically subtraction instead of addition) if $negated is true.
Parameters
- $dateTime : DateTimeInterface
- $negated : bool = false
Return values
CarbonInterfacecopy()
Get a copy of the instance.
public
copy() : static
Return values
staticcreate()
Create a new CarbonInterval instance from specific values.
public
static create([int $years = null ][, int $months = null ][, int $weeks = null ][, int $days = null ][, int $hours = null ][, int $minutes = null ][, int $seconds = null ][, int $microseconds = null ]) : static
This is an alias for the constructor that allows better fluent syntax as it allows you to do CarbonInterval::create(1)->fn() rather than (new CarbonInterval(1))->fn().
Parameters
- $years : int = null
- $months : int = null
- $weeks : int = null
- $days : int = null
- $hours : int = null
- $minutes : int = null
- $seconds : int = null
- $microseconds : int = null
Tags
Return values
staticcreateFromDateString()
Sets up a DateInterval from the relative parts of the string.
public
static createFromDateString(string $datetime) : static
Parameters
- $datetime : string
Tags
Return values
staticcreateFromFormat()
Parse a string into a new CarbonInterval object according to the specified format.
public
static createFromFormat(string $format, string|null $interval) : static
Parameters
- $format : string
-
Format of the $interval input string
- $interval : string|null
-
Input string to convert into an interval
Tags
Return values
staticday()
public
static day(mixed $days) : CarbonInterval
Alias for days()
Parameters
- $days : mixed
Return values
CarbonIntervaldays()
public
static days(mixed $days) : CarbonInterval
Create instance specifying a number of days or modify the number of days if called on an instance.
Parameters
- $days : mixed
Return values
CarbonIntervaldaysExcludeWeeks()
public
static daysExcludeWeeks(mixed $days) : CarbonInterval
Create instance specifying a number of days or modify the number of days (keeping the current number of weeks) if called on an instance.
Parameters
- $days : mixed
Return values
CarbonIntervaldayz()
public
static dayz(mixed $days) : CarbonInterval
Alias for days()
Parameters
- $days : mixed
Return values
CarbonIntervaldayzExcludeWeeks()
public
static dayzExcludeWeeks(mixed $days) : CarbonInterval
Alias for daysExcludeWeeks()
Parameters
- $days : mixed
Return values
CarbonIntervaldiff()
Create an interval from the difference between 2 dates.
public
static diff(Carbon|DateTimeInterface|mixed $start[, Carbon|DateTimeInterface|mixed $end = null ][, bool $absolute = false ][, array<string|int, mixed> $skip = [] ]) : static
Parameters
- $start : Carbon|DateTimeInterface|mixed
- $end : Carbon|DateTimeInterface|mixed = null
- $absolute : bool = false
- $skip : array<string|int, mixed> = []
Return values
staticdivide()
Divide and cascade current instance by a given divider.
public
divide(float|int $divider) : $this
Parameters
- $divider : float|int
Return values
$thisenableFloatSetters()
This option allow you to opt-in for the Carbon 3 behavior where float values will no longer be cast to integer (so truncated).
public
static enableFloatSetters([bool $floatSettersEnabled = true ]) : void
⚠️ This settings will be applied globally, which mean your whole application code including the third-party dependencies that also may use Carbon will adopt the new behavior.
Parameters
- $floatSettersEnabled : bool = true
end()
Return the end date if interval was created from a difference between 2 dates.
public
end() : CarbonInterface|null
Return values
CarbonInterface|nulleq()
Determines if the instance is equal to another
public
eq(CarbonInterval|DateInterval|mixed $interval) : bool
Parameters
- $interval : CarbonInterval|DateInterval|mixed
Tags
Return values
boolequalTo()
Determines if the instance is equal to another
public
equalTo(CarbonInterval|DateInterval|mixed $interval) : bool
Parameters
- $interval : CarbonInterval|DateInterval|mixed
Return values
boolfloor()
Round the current instance second with given precision if specified.
public
floor([DateInterval|string|float|int $precision = 1 ]) : $this
Parameters
- $precision : DateInterval|string|float|int = 1
Tags
Return values
$thisfloorCenturies()
public
floorCenturies(int|float $precision = 1) : $this
Truncate the current instance century with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorCentury()
public
floorCentury(int|float $precision = 1) : $this
Truncate the current instance century with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorDay()
public
floorDay(int|float $precision = 1) : $this
Truncate the current instance day with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorDays()
public
floorDays(int|float $precision = 1) : $this
Truncate the current instance day with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorDecade()
public
floorDecade(int|float $precision = 1) : $this
Truncate the current instance decade with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorDecades()
public
floorDecades(int|float $precision = 1) : $this
Truncate the current instance decade with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorHour()
public
floorHour(int|float $precision = 1) : $this
Truncate the current instance hour with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorHours()
public
floorHours(int|float $precision = 1) : $this
Truncate the current instance hour with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorMicrosecond()
public
floorMicrosecond(int|float $precision = 1) : $this
Truncate the current instance microsecond with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorMicroseconds()
public
floorMicroseconds(int|float $precision = 1) : $this
Truncate the current instance microsecond with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorMillennia()
public
floorMillennia(int|float $precision = 1) : $this
Truncate the current instance millennium with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorMillennium()
public
floorMillennium(int|float $precision = 1) : $this
Truncate the current instance millennium with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorMillisecond()
public
floorMillisecond(int|float $precision = 1) : $this
Truncate the current instance millisecond with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorMilliseconds()
public
floorMilliseconds(int|float $precision = 1) : $this
Truncate the current instance millisecond with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorMinute()
public
floorMinute(int|float $precision = 1) : $this
Truncate the current instance minute with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorMinutes()
public
floorMinutes(int|float $precision = 1) : $this
Truncate the current instance minute with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorMonth()
public
floorMonth(int|float $precision = 1) : $this
Truncate the current instance month with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorMonths()
public
floorMonths(int|float $precision = 1) : $this
Truncate the current instance month with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorQuarter()
public
floorQuarter(int|float $precision = 1) : $this
Truncate the current instance quarter with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorQuarters()
public
floorQuarters(int|float $precision = 1) : $this
Truncate the current instance quarter with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorSecond()
public
floorSecond(int|float $precision = 1) : $this
Truncate the current instance second with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorSeconds()
public
floorSeconds(int|float $precision = 1) : $this
Truncate the current instance second with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorUnit()
Truncate the current instance at the given unit with given precision if specified.
public
floorUnit(string $unit[, float|int|string|DateInterval|null $precision = 1 ]) : $this
Parameters
- $unit : string
- $precision : float|int|string|DateInterval|null = 1
Tags
Return values
$thisfloorWeek()
public
floorWeek(int|float $precision = 1) : $this
Truncate the current instance day with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorWeeks()
public
floorWeeks(int|float $precision = 1) : $this
Truncate the current instance day with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorYear()
public
floorYear(int|float $precision = 1) : $this
Truncate the current instance year with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisfloorYears()
public
floorYears(int|float $precision = 1) : $this
Truncate the current instance year with given precision.
Parameters
- $precision = 1 : int|float
Return values
$thisforHumans()
Get the current interval in a human readable format in the current locale.
public
forHumans([int|array<string|int, mixed> $syntax = null ][, bool $short = false ][, int $parts = self::NO_LIMIT ][, int $options = null ]) : string
Parameters
- $syntax : int|array<string|int, mixed> = null
-
if array passed, parameters will be extracted from it, the array may contain: ⦿ 'syntax' entry (see below) ⦿ 'short' entry (see below) ⦿ 'parts' entry (see below) ⦿ 'options' entry (see below) ⦿ 'skip' entry, list of units to skip (array of strings or a single string,
it can be the unit name (singular or plural) or its shortcut
(y, m, w, d, h, min, s, ms, µs). ⦿ 'aUnit' entry, prefer "an hour" over "1 hour" if true ⦿ 'altNumbers' entry, use alternative numbers if available(from the current language if true is passed, from the given language(s)
if array or string is passed) ⦿ 'join' entry determines how to join multiple parts of the string- if $join is a string, it's used as a joiner glue
- if $join is a callable/closure, it get the list of string and should return a string- if $join is an array, the first item will be the default glue, and the second item
will be used instead of the glue for the last item- if $join is true, it will be guessed from the locale ('list' translation file entry)
- if $join is missing, a space will be used as glue ⦿ 'minimumUnit' entry determines the smallest unit of time to display can be long or ` short form of the units, e.g. 'hour' or 'h' (default value: s) ⦿ 'locale' language in which the diff should be output (has no effect if 'translator' key is set) ⦿ 'translator' a custom translator to use to translator the output. if int passed, it adds modifiers: Possible values:- CarbonInterface::DIFF_ABSOLUTE no modifiers
- CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
- CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier Default value: CarbonInterface::DIFF_ABSOLUTE
- $short : bool = false
-
displays short format of time units
- $parts : int = self::NO_LIMIT
-
maximum number of parts to display (default value: -1: no limits)
- $options : int = null
-
human diff options
Tags
Return values
stringformat()
public
format(string $format) : string
Parameters
- $format : string
Return values
stringfromString()
Creates a CarbonInterval from string.
public
static fromString(string $intervalDefinition) : static
Format:
Suffix | Unit | Example | DateInterval expression |
---|---|---|---|
y | years | 1y | P1Y |
mo | months | 3mo | P3M |
w | weeks | 2w | P2W |
d | days | 28d | P28D |
h | hours | 4h | PT4H |
m | minutes | 12m | PT12M |
s | seconds | 59s | PT59S |
e. g. 1w 3d 4h 32m 23s
is converted to 10 days 4 hours 32 minutes and 23 seconds.
Special cases:
- An empty string will return a zero interval
- Fractions are allowed for weeks, days, hours and minutes and will be converted and rounded to the next smaller value (caution: 0.5w = 4d)
Parameters
- $intervalDefinition : string
Tags
Return values
staticget()
Get a part of the CarbonInterval object.
public
get(Unit|string $name) : int|float|string|null
Parameters
- $name : Unit|string
Return values
int|float|string|nullgetCascadeFactors()
Mapping of units and factors for cascading.
public
static getCascadeFactors() : array<string|int, mixed>
Should only be modified by changing the factors or referenced constants.
Return values
array<string|int, mixed>getClock()
public
getClock() : WrapperClock|null
Return values
WrapperClock|nullgetDateIntervalSpec()
Get the interval_spec string of a date interval.
public
static getDateIntervalSpec(DateInterval $interval[, bool $microseconds = false ][, array<string|int, mixed> $skip = [] ]) : string
Parameters
- $interval : DateInterval
- $microseconds : bool = false
- $skip : array<string|int, mixed> = []
Return values
stringgetDaysPerWeek()
Returns current config for days per week.
public
static getDaysPerWeek() : int|float
Return values
int|floatgetFactor()
Returns the factor for a given source-to-target couple.
public
static getFactor(string $source, string $target) : int|float|null
Parameters
- $source : string
- $target : string
Return values
int|float|nullgetFactorWithDefault()
Returns the factor for a given source-to-target couple if set, else try to find the appropriate constant as the factor, such as Carbon::DAYS_PER_WEEK.
public
static getFactorWithDefault(string $source, string $target) : int|float|null
Parameters
- $source : string
- $target : string
Return values
int|float|nullgetHoursPerDay()
Returns current config for hours per day.
public
static getHoursPerDay() : int|float
Return values
int|floatgetMicrosecondsPerMillisecond()
Returns current config for microseconds per second.
public
static getMicrosecondsPerMillisecond() : int|float
Return values
int|floatgetMillisecondsPerSecond()
Returns current config for microseconds per second.
public
static getMillisecondsPerSecond() : int|float
Return values
int|floatgetMinutesPerHour()
Returns current config for minutes per hour.
public
static getMinutesPerHour() : int|float
Return values
int|floatgetNonZeroValues()
Returns interval non-zero values as an array where key are the unit names and values the counts.
public
getNonZeroValues() : array<string|int, int>
Return values
array<string|int, int>getSecondsPerMinute()
Returns current config for seconds per minute.
public
static getSecondsPerMinute() : int|float
Return values
int|floatgetSettings()
Returns current local settings.
public
getSettings() : array<string|int, mixed>
Return values
array<string|int, mixed>getStep()
Get the dynamic step in use.
public
getStep() : Closure
Return values
ClosuregetValuesSequence()
Returns interval values as an array where key are the unit names and values the counts from the biggest non-zero one the the smallest non-zero one.
public
getValuesSequence() : array<string|int, int>
Return values
array<string|int, int>greaterThan()
Determines if the instance is greater (longer) than another
public
greaterThan(CarbonInterval|DateInterval|mixed $interval) : bool
Parameters
- $interval : CarbonInterval|DateInterval|mixed
Return values
boolgreaterThanOrEqualTo()
Determines if the instance is greater (longer) than or equal to another
public
greaterThanOrEqualTo(CarbonInterval|DateInterval|mixed $interval) : bool
Parameters
- $interval : CarbonInterval|DateInterval|mixed
Return values
boolgt()
Determines if the instance is greater (longer) than another
public
gt(CarbonInterval|DateInterval|mixed $interval) : bool
Parameters
- $interval : CarbonInterval|DateInterval|mixed
Tags
Return values
boolgte()
Determines if the instance is greater (longer) than or equal to another
public
gte(CarbonInterval|DateInterval|mixed $interval) : bool
Parameters
- $interval : CarbonInterval|DateInterval|mixed
Tags
Return values
boolhasMacro()
Check if macro is registered.
public
static hasMacro(string $name) : bool
Parameters
- $name : string
Return values
boolhasNegativeValues()
public
hasNegativeValues() : bool
Return values
boolhasPositiveValues()
public
hasPositiveValues() : bool
Return values
boolhour()
public
static hour(mixed $hours) : CarbonInterval
Alias for hours()
Parameters
- $hours : mixed
Return values
CarbonIntervalhours()
public
static hours(mixed $hours) : CarbonInterval
Create instance specifying a number of hours or modify the number of hours if called on an instance.
Parameters
- $hours : mixed
Return values
CarbonIntervalinstance()
Create a CarbonInterval instance from a DateInterval one. Can not instance DateInterval objects created from DateTime::diff() as you can't externally set the $days field.
public
static instance(DateInterval $interval[, array<string|int, mixed> $skip = [] ][, bool $skipCopy = false ]) : static
Parameters
- $interval : DateInterval
- $skip : array<string|int, mixed> = []
- $skipCopy : bool = false
-
set to true to return the passed object (without copying it) if it's already of the current class
Return values
staticinvert()
Invert the interval.
public
invert([bool|int $inverted = null ]) : $this
Parameters
- $inverted : bool|int = null
-
if a parameter is passed, the passed value cast as 1 or 0 is used as the new value of the ->invert property.
Return values
$thisisBetween()
Determines if the instance is between two others
public
isBetween(CarbonInterval|DateInterval|mixed $interval1, CarbonInterval|DateInterval|mixed $interval2[, bool $equal = true ]) : bool
Parameters
- $interval1 : CarbonInterval|DateInterval|mixed
- $interval2 : CarbonInterval|DateInterval|mixed
- $equal : bool = true
-
Indicates if an equal to comparison should be done
Tags
Return values
boolisEmpty()
Returns true if the interval is empty for each unit.
public
isEmpty() : bool
Return values
boollessThan()
Determines if the instance is less (shorter) than another
public
lessThan(CarbonInterval|DateInterval|mixed $interval) : bool
Parameters
- $interval : CarbonInterval|DateInterval|mixed
Return values
boollessThanOrEqualTo()
Determines if the instance is less (shorter) than or equal to another
public
lessThanOrEqualTo(CarbonInterval|DateInterval|mixed $interval) : bool
Parameters
- $interval : CarbonInterval|DateInterval|mixed
Return values
boollt()
Determines if the instance is less (shorter) than another
public
lt(CarbonInterval|DateInterval|mixed $interval) : bool
Parameters
- $interval : CarbonInterval|DateInterval|mixed
Tags
Return values
boollte()
Determines if the instance is less (shorter) than or equal to another
public
lte(CarbonInterval|DateInterval|mixed $interval) : bool
Parameters
- $interval : CarbonInterval|DateInterval|mixed
Tags
Return values
boolmacro()
Register a custom macro.
public
static macro(string $name, callable|null $macro) : void
Pass null macro to remove it.
Parameters
- $name : string
- $macro : callable|null
Tags
make()
Make a CarbonInterval instance from given variable if possible.
public
static make(mixed|int|DateInterval|string|Closure|Unit|null $interval[, Unit|string|null $unit = null ][, bool $skipCopy = false ]) : static|null
Always return a new instance. Parse only strings and only these likely to be intervals (skip dates and recurrences). Throw an exception for invalid format, but otherwise return null.
Parameters
- $interval : mixed|int|DateInterval|string|Closure|Unit|null
-
interval or number of the given $unit
- $unit : Unit|string|null = null
-
if specified, $interval must be an integer
- $skipCopy : bool = false
-
set to true to return the passed object (without copying it) if it's already of the current class
Return values
static|nullmicrosecond()
public
static microsecond(mixed $microseconds) : CarbonInterval
Alias for microseconds()
Parameters
- $microseconds : mixed
Return values
CarbonIntervalmicroseconds()
public
static microseconds(mixed $microseconds) : CarbonInterval
Create instance specifying a number of microseconds or modify the number of microseconds if called on an instance.
Parameters
- $microseconds : mixed
Return values
CarbonIntervalmillisecond()
public
static millisecond(mixed $milliseconds) : CarbonInterval
Alias for milliseconds()
Parameters
- $milliseconds : mixed
Return values
CarbonIntervalmilliseconds()
public
static milliseconds(mixed $milliseconds) : CarbonInterval
Create instance specifying a number of milliseconds or modify the number of milliseconds if called on an instance.
Parameters
- $milliseconds : mixed
Return values
CarbonIntervalminus()
Add given parameters to the current interval.
public
minus([int $years = 0 ][, int $months = 0 ][, int|float $weeks = 0 ][, int|float $days = 0 ][, int|float $hours = 0 ][, int|float $minutes = 0 ][, int|float $seconds = 0 ][, int|float $microseconds = 0 ]) : $this
Parameters
- $years : int = 0
- $months : int = 0
- $weeks : int|float = 0
- $days : int|float = 0
- $hours : int|float = 0
- $minutes : int|float = 0
- $seconds : int|float = 0
- $microseconds : int|float = 0
Return values
$thisminute()
public
static minute(mixed $minutes) : CarbonInterval
Alias for minutes()
Parameters
- $minutes : mixed
Return values
CarbonIntervalminutes()
public
static minutes(mixed $minutes) : CarbonInterval
Create instance specifying a number of minutes or modify the number of minutes if called on an instance.
Parameters
- $minutes : mixed
Return values
CarbonIntervalmixin()
Register macros from a mixin object.
public
static mixin(object|string $mixin) : void
Parameters
- $mixin : object|string
Tags
month()
public
static month(mixed $months) : CarbonInterval
Alias for months()
Parameters
- $months : mixed
Return values
CarbonIntervalmonths()
public
static months(mixed $months) : CarbonInterval
Create instance specifying a number of months or modify the number of months if called on an instance.
Parameters
- $months : mixed
Return values
CarbonIntervalmultiply()
Multiply and cascade current instance by a given factor.
public
multiply(float|int $factor) : $this
Parameters
- $factor : float|int
Return values
$thisne()
Determines if the instance is not equal to another
public
ne(CarbonInterval|DateInterval|mixed $interval) : bool
Parameters
- $interval : CarbonInterval|DateInterval|mixed
Tags
Return values
boolnotEqualTo()
Determines if the instance is not equal to another
public
notEqualTo(CarbonInterval|DateInterval|mixed $interval) : bool
Parameters
- $interval : CarbonInterval|DateInterval|mixed
Return values
booloptimize()
Get rid of the original input, start date and end date that may be kept in memory.
public
optimize() : $this
Return values
$thisoriginal()
Return the original source used to create the current interval.
public
original() : array<string|int, mixed>|int|string|DateInterval|mixed|null
Return values
array<string|int, mixed>|int|string|DateInterval|mixed|nullparseFromLocale()
Creates a CarbonInterval from string using a different locale.
public
static parseFromLocale(string $interval[, string|null $locale = null ]) : static
Parameters
- $interval : string
-
interval string in the given language (may also contain English).
- $locale : string|null = null
-
if locale is null or not specified, current global locale will be used instead.
Return values
staticplus()
Add given parameters to the current interval.
public
plus([int $years = 0 ][, int $months = 0 ][, int|float $weeks = 0 ][, int|float $days = 0 ][, int|float $hours = 0 ][, int|float $minutes = 0 ][, int|float $seconds = 0 ][, int|float $microseconds = 0 ]) : $this
Parameters
- $years : int = 0
- $months : int = 0
- $weeks : int|float = 0
- $days : int|float = 0
- $hours : int|float = 0
- $minutes : int|float = 0
- $seconds : int|float = 0
- $microseconds : int|float = 0
Return values
$thisresetToStringFormat()
Reset the format used to the default when type juggling a Carbon instance to a string
public
static resetToStringFormat() : void
round()
Round the current instance second with given precision if specified.
public
round([float|int|string|DateInterval|null $precision = 1 ][, string $function = 'round' ]) : $this
Parameters
- $precision : float|int|string|DateInterval|null = 1
- $function : string = 'round'
Tags
Return values
$thisroundCenturies()
public
roundCenturies(int|float $precision = 1, string $function = "round") : $this
Round the current instance century with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundCentury()
public
roundCentury(int|float $precision = 1, string $function = "round") : $this
Round the current instance century with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundDay()
public
roundDay(int|float $precision = 1, string $function = "round") : $this
Round the current instance day with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundDays()
public
roundDays(int|float $precision = 1, string $function = "round") : $this
Round the current instance day with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundDecade()
public
roundDecade(int|float $precision = 1, string $function = "round") : $this
Round the current instance decade with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundDecades()
public
roundDecades(int|float $precision = 1, string $function = "round") : $this
Round the current instance decade with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundHour()
public
roundHour(int|float $precision = 1, string $function = "round") : $this
Round the current instance hour with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundHours()
public
roundHours(int|float $precision = 1, string $function = "round") : $this
Round the current instance hour with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundMicrosecond()
public
roundMicrosecond(int|float $precision = 1, string $function = "round") : $this
Round the current instance microsecond with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundMicroseconds()
public
roundMicroseconds(int|float $precision = 1, string $function = "round") : $this
Round the current instance microsecond with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundMillennia()
public
roundMillennia(int|float $precision = 1, string $function = "round") : $this
Round the current instance millennium with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundMillennium()
public
roundMillennium(int|float $precision = 1, string $function = "round") : $this
Round the current instance millennium with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundMillisecond()
public
roundMillisecond(int|float $precision = 1, string $function = "round") : $this
Round the current instance millisecond with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundMilliseconds()
public
roundMilliseconds(int|float $precision = 1, string $function = "round") : $this
Round the current instance millisecond with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundMinute()
public
roundMinute(int|float $precision = 1, string $function = "round") : $this
Round the current instance minute with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundMinutes()
public
roundMinutes(int|float $precision = 1, string $function = "round") : $this
Round the current instance minute with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundMonth()
public
roundMonth(int|float $precision = 1, string $function = "round") : $this
Round the current instance month with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundMonths()
public
roundMonths(int|float $precision = 1, string $function = "round") : $this
Round the current instance month with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundQuarter()
public
roundQuarter(int|float $precision = 1, string $function = "round") : $this
Round the current instance quarter with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundQuarters()
public
roundQuarters(int|float $precision = 1, string $function = "round") : $this
Round the current instance quarter with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundSecond()
public
roundSecond(int|float $precision = 1, string $function = "round") : $this
Round the current instance second with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundSeconds()
public
roundSeconds(int|float $precision = 1, string $function = "round") : $this
Round the current instance second with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundUnit()
Round the current instance at the given unit with given precision if specified and the given function.
public
roundUnit(string $unit[, DateInterval|string|int|float $precision = 1 ][, string $function = 'round' ]) : static
Parameters
- $unit : string
- $precision : DateInterval|string|int|float = 1
- $function : string = 'round'
Tags
Return values
staticroundWeek()
public
roundWeek(int|float $precision = 1, string $function = "round") : $this
Round the current instance day with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundWeeks()
public
roundWeeks(int|float $precision = 1, string $function = "round") : $this
Round the current instance day with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundYear()
public
roundYear(int|float $precision = 1, string $function = "round") : $this
Round the current instance year with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thisroundYears()
public
roundYears(int|float $precision = 1, string $function = "round") : $this
Round the current instance year with given precision using the given function.
Parameters
- $precision = 1 : int|float
- $function = "round" : string
Return values
$thissecond()
public
static second(mixed $seconds) : CarbonInterval
Alias for seconds()
Parameters
- $seconds : mixed
Return values
CarbonIntervalseconds()
public
static seconds(mixed $seconds) : CarbonInterval
Create instance specifying a number of seconds or modify the number of seconds if called on an instance.
Parameters
- $seconds : mixed
Return values
CarbonIntervalset()
Set a part of the CarbonInterval object.
public
set(Unit|string|array<string|int, mixed> $name[, int $value = null ]) : $this
Parameters
- $name : Unit|string|array<string|int, mixed>
- $value : int = null
Tags
Return values
$thissetCascadeFactors()
Set default cascading factors for ->cascade() method.
public
static setCascadeFactors(array<string|int, mixed> $cascadeFactors) : mixed
Parameters
- $cascadeFactors : array<string|int, mixed>
setStep()
Set a step to apply instead of a fixed interval to get the new date.
public
setStep(Closure|null $step) : void
Or pass null to switch to fixed interval.
Parameters
- $step : Closure|null
setTimezone()
Set the instance's timezone from a string or object.
public
setTimezone(DateTimeZone|string|int $timezone) : static
Parameters
- $timezone : DateTimeZone|string|int
Return values
staticsettings()
Set specific options.
public
settings(array<string|int, mixed> $settings) : $this|static
- strictMode: true|false|null
- monthOverflow: true|false|null
- yearOverflow: true|false|null
- humanDiffOptions: int|null
- toStringFormat: string|Closure|null
- toJsonFormat: string|Closure|null
- locale: string|null
- timezone: \DateTimeZone|string|int|null
- macros: array|null
- genericMacros: array|null
Parameters
- $settings : array<string|int, mixed>
Return values
$this|staticsetToStringFormat()
public
static setToStringFormat(string|Closure|null $format) : void
Parameters
- $format : string|Closure|null
Tags
shares()
Divide current instance by a given divider. shares() is naive, it divides each unit separately and the result is rounded for each unit. So 5 hours and 20 minutes shared by 3 becomes 2 hours and 7 minutes.
public
shares(float|int $divider) : $this
Use shares() when you want a fast and approximated calculation that does not cascade units.
For a precise and cascaded calculation,
Parameters
- $divider : float|int
Tags
Return values
$thisshiftTimezone()
Set the instance's timezone from a string or object and add/subtract the offset difference.
public
shiftTimezone(DateTimeZone|string|int $timezone) : static
Parameters
- $timezone : DateTimeZone|string|int
Return values
staticspec()
Get the interval_spec string.
public
spec([bool $microseconds = false ]) : string
Parameters
- $microseconds : bool = false
Return values
stringstart()
Return the start date if interval was created from a difference between 2 dates.
public
start() : CarbonInterface|null
Return values
CarbonInterface|nullstepBy()
Decompose the current interval into
public
stepBy(mixed|int|DateInterval|string|Closure|Unit|null $interval[, Unit|string|null $unit = null ]) : CarbonPeriod
Parameters
- $interval : mixed|int|DateInterval|string|Closure|Unit|null
-
interval or number of the given $unit
- $unit : Unit|string|null = null
-
if specified, $interval must be an integer
Return values
CarbonPeriodsub()
Subtract the passed interval to the current instance.
public
sub(string|DateInterval $unit[, int|float $value = 1 ]) : $this
Parameters
- $unit : string|DateInterval
- $value : int|float = 1
Return values
$thissubDays()
public
subDays(int|float $days) : $this
Subtract given number of days to the current interval
Parameters
- $days : int|float
Return values
$thissubHours()
public
subHours(int|float $hours) : $this
Subtract given number of hours to the current interval
Parameters
- $hours : int|float
Return values
$thissubMicroseconds()
public
subMicroseconds(int|float $microseconds) : $this
Subtract given number of microseconds to the current interval
Parameters
- $microseconds : int|float
Return values
$thissubMilliseconds()
public
subMilliseconds(int|float $milliseconds) : $this
Subtract given number of milliseconds to the current interval
Parameters
- $milliseconds : int|float
Return values
$thissubMinutes()
public
subMinutes(int|float $minutes) : $this
Subtract given number of minutes to the current interval
Parameters
- $minutes : int|float
Return values
$thissubMonths()
public
subMonths(int $months) : $this
Subtract given number of months to the current interval
Parameters
- $months : int
Return values
$thissubSeconds()
public
subSeconds(int|float $seconds) : $this
Subtract given number of seconds to the current interval
Parameters
- $seconds : int|float
Return values
$thissubtract()
Subtract the passed interval to the current instance.
public
subtract(string|DateInterval $unit[, int|float $value = 1 ]) : $this
Parameters
- $unit : string|DateInterval
- $value : int|float = 1
Return values
$thissubWeeks()
public
subWeeks(int|float $weeks) : $this
Subtract given number of weeks to the current interval
Parameters
- $weeks : int|float
Return values
$thissubYears()
public
subYears(int $years) : $this
Subtract given number of years to the current interval
Parameters
- $years : int
Return values
$thistimes()
Multiply current instance given number of times. times() is naive, it multiplies each unit (so day can be greater than 31, hour can be greater than 23, etc.) and the result is rounded separately for each unit.
public
times(float|int $factor) : $this
Use times() when you want a fast and approximated calculation that does not cascade units.
For a precise and cascaded calculation,
Parameters
- $factor : float|int
Tags
Return values
$thistoArray()
Returns interval values as an array where key are the unit names and values the counts.
public
toArray() : array<string|int, int>
Return values
array<string|int, int>toDateInterval()
Return native DateInterval PHP object matching the current instance.
public
toDateInterval() : DateInterval
Tags
Return values
DateIntervaltoPeriod()
Convert the interval to a CarbonPeriod.
public
toPeriod(DateTimeInterface|string|int ...$params) : CarbonPeriod
Parameters
- $params : DateTimeInterface|string|int
-
Start date, [end date or recurrences] and optional settings.
Return values
CarbonPeriodtotal()
Get amount of given unit equivalent to the interval.
public
total(string $unit) : float
Parameters
- $unit : string
Tags
Return values
floatweek()
public
static week(mixed $weeks) : CarbonInterval
Alias for weeks()
Parameters
- $weeks : mixed
Return values
CarbonIntervalweeks()
public
static weeks(mixed $weeks) : CarbonInterval
Create instance specifying a number of weeks or modify the number of weeks if called on an instance.
Parameters
- $weeks : mixed
Return values
CarbonIntervalweeksAndDays()
Allow setting of weeks and days to be cumulative.
public
weeksAndDays(int $weeks, int $days) : static
Parameters
- $weeks : int
-
Number of weeks to set
- $days : int
-
Number of days to set
Return values
staticyear()
public
static year(mixed $years) : CarbonInterval
Alias for years()
Parameters
- $years : mixed
Return values
CarbonIntervalyears()
public
static years(mixed $years) : CarbonInterval
Create instance specifying a number of years or modify the number of years if called on an instance.
Parameters
- $years : mixed
Return values
CarbonIntervaladdExtraDebugInfos()
protected
addExtraDebugInfos(array<string|int, mixed> &$infos) : void
Parameters
- $infos : array<string|int, mixed>
bindMacroContext()
Stack a Carbon context from inside calls of self::this() and execute a given action.
protected
static bindMacroContext(self|null $context, callable $callable) : mixed
Parameters
- $context : self|null
- $callable : callable
callMacro()
Call given macro.
protected
callMacro(string $name, array<string|int, mixed> $parameters) : mixed
Parameters
- $name : string
- $parameters : array<string|int, mixed>
callRoundMethod()
protected
callRoundMethod(string $method, array<string|int, mixed> $parameters) : static|null
Parameters
- $method : string
- $parameters : array<string|int, mixed>
Return values
static|nullcontext()
Return the current context from inside a macro callee or a null if static.
protected
static context() : static|null
Return values
static|nullcopyProperties()
protected
copyProperties(self $interval[, mixed $ignoreSign = false ]) : static
Parameters
- $interval : self
- $ignoreSign : mixed = false
Return values
staticgetDefaultCascadeFactors()
protected
static getDefaultCascadeFactors() : array<string|int, mixed>
Return values
array<string|int, mixed>getForHumansInitialVariables()
protected
getForHumansInitialVariables(mixed $syntax, mixed $short) : array<string|int, mixed>
Parameters
- $syntax : mixed
- $short : mixed
Return values
array<string|int, mixed>getForHumansParameters()
protected
getForHumansParameters([mixed $syntax = null ][, mixed $short = false ][, mixed $parts = self::NO_LIMIT ][, mixed $options = null ]) : array<string|int, mixed>
Parameters
- $syntax : mixed = null
- $short : mixed = false
- $parts : mixed = self::NO_LIMIT
- $options : mixed = null
Return values
array<string|int, mixed>getRoundingMethodFromOptions()
protected
static getRoundingMethodFromOptions(int $options) : string|null
Parameters
- $options : int
Return values
string|nullisLocalStrictModeEnabled()
protected
isLocalStrictModeEnabled() : bool
Return values
boolmakeFromString()
protected
static makeFromString(string $interval) : self|null
Parameters
- $interval : string
Return values
self|nullresolveInterval()
protected
resolveInterval(mixed $interval) : self|null
Parameters
- $interval : mixed
Return values
self|nullroundWith()
protected
roundWith(DateInterval|string|float|int $precision, callable|string $function) : static|null
Parameters
- $precision : DateInterval|string|float|int
- $function : callable|string
Return values
static|nullsolveNegativeInterval()
protected
solveNegativeInterval() : static
Return values
staticthis()
Return the current context from inside a macro callee or a new one if static.
protected
static this() : static
Return values
staticassertSafeForInteger()
Throw an exception if precision loss when storing the given value as an integer would be >= 1.0.
private
assertSafeForInteger(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
castIntervalToClass()
private
static castIntervalToClass(DateInterval $interval, string $className[, array<string|int, mixed> $skip = [] ]) : T
Parameters
- $interval : DateInterval
- $className : string
- $skip : array<string|int, mixed> = []
Tags
Return values
TcheckIntegerValue()
private
checkIntegerValue(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
checkStartAndEnd()
private
checkStartAndEnd() : void
copyNegativeUnits()
private
static copyNegativeUnits(DateInterval $from, DateInterval $to) : void
Parameters
- $from : DateInterval
- $to : DateInterval
copyStep()
private
static copyStep(self $from, self $to) : void
Parameters
- $from : self
- $to : self
doCascade()
private
doCascade(bool $deep) : static
Parameters
- $deep : bool
Return values
staticgetAnonymousClassCodeForTrait()
private
static getAnonymousClassCodeForTrait(string $trait) : string
Parameters
- $trait : string
Return values
stringgetFactory()
private
getFactory() : Factory
Return values
FactorygetFlipCascadeFactors()
private
static getFlipCascadeFactors() : array<string|int, mixed>
Return values
array<string|int, mixed>getInnerValues()
private
getInnerValues() : array<string|int, mixed>
Return values
array<string|int, mixed>getMagicParameter()
private
getMagicParameter(array<string|int, mixed> $parameters, int $index, string $key, mixed $default) : mixed
Parameters
- $parameters : array<string|int, mixed>
- $index : int
- $key : string
- $default : mixed
getMixableMethods()
private
static getMixableMethods(self $context) : Generator
Parameters
- $context : self
Return values
GeneratorhandleDecimalPart()
private
handleDecimalPart(string $unit, mixed $value, mixed $integerValue) : void
Parameters
- $unit : string
- $value : mixed
- $integerValue : mixed
initLocalFactory()
private
initLocalFactory() : void
invertCascade()
private
invertCascade(array<string|int, mixed> $values) : static
Parameters
- $values : array<string|int, mixed>
Return values
staticloadMixinClass()
private
static loadMixinClass(object|string $mixin) : void
Parameters
- $mixin : object|string
Tags
loadMixinTrait()
private
static loadMixinTrait(string $trait) : void
Parameters
- $trait : string
needsDeclension()
private
needsDeclension(string $mode, int $index, int $parts) : bool
Parameters
- $mode : string
- $index : int
- $parts : int
Return values
boolresolveCarbon()
Convert DateTimeImmutable instance to CarbonImmutable instance and DateTime instance to Carbon instance.
private
resolveCarbon(DateTimeInterface $dateTime) : Carbon|CarbonImmutable
Parameters
- $dateTime : DateTimeInterface
Return values
Carbon|CarbonImmutablesetSetting()
private
setSetting(string $setting, mixed $value) : $this
Parameters
- $setting : string
- $value : mixed
Return values
$thisstandardizeUnit()
private
static standardizeUnit(string $unit) : string
Parameters
- $unit : string
Return values
stringtransmitFactory()
Trigger the given action using the local factory of the object, so it will be transmitted to any object also using this trait and calling initLocalFactory() in its constructor.
private
transmitFactory(Closure $action) : T
Parameters
- $action : Closure
Tags
Return values
TwithOriginal()
private
static withOriginal(T $interval, mixed $original) : T
Parameters
- $interval : T
- $original : mixed