Menu

## CarbonInterval extends DateInterval
in package
implements CarbonConverterInterface Uses LocalFactory, IntervalRounding, IntervalStep, MagicParameter, Mixin, Options, ToStringFormat

CarbonInterval.php : 194

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

CarbonConverterInterface

#### 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

CarbonInterval.php : 214
`public mixed NEGATIVE = -1`

#### NO_LIMIT

CarbonInterval.php : 211

Unlimited parts for forHumans() method.

`public mixed NO_LIMIT = -1`

INF constant can be used instead.

#### PERIOD_DAYS

CarbonInterval.php : 222
`public mixed PERIOD_DAYS = 'D'`

#### PERIOD_HOURS

CarbonInterval.php : 224
`public mixed PERIOD_HOURS = 'H'`

#### PERIOD_MINUTES

CarbonInterval.php : 225
`public mixed PERIOD_MINUTES = 'M'`

#### PERIOD_MONTHS

CarbonInterval.php : 221
`public mixed PERIOD_MONTHS = 'M'`

#### PERIOD_PREFIX

CarbonInterval.php : 219

Interval spec period designators

`public mixed PERIOD_PREFIX = 'P'`

#### PERIOD_SECONDS

CarbonInterval.php : 226
`public mixed PERIOD_SECONDS = 'S'`

#### PERIOD_TIME_PREFIX

CarbonInterval.php : 223
`public mixed PERIOD_TIME_PREFIX = 'T'`

#### PERIOD_YEARS

CarbonInterval.php : 220
`public mixed PERIOD_YEARS = 'Y'`

#### POSITIVE

CarbonInterval.php : 213
`public mixed POSITIVE = 1`

#### SPECIAL_TRANSLATIONS

CarbonInterval.php : 228
`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

CarbonInterval.php : 0
`public int $daysExcludeWeeks`

alias of dayzExcludeWeeks

#### $dayz

CarbonInterval.php : 0
`public int $dayz`

Total days of the current interval (weeks * 7 + days).

#### $dayzExcludeWeeks

CarbonInterval.php : 0
`public int $dayzExcludeWeeks`

Total days remaining in the final week of the current instance (days % 7).

#### $hours

CarbonInterval.php : 0
`public int $hours`

Total hours of the current interval.

#### $locale read-only

CarbonInterval.php : 0
`public string $locale`

locale of the current instance

#### $microExcludeMilli

CarbonInterval.php : 0
`public int $microExcludeMilli`

Remaining microseconds without the milliseconds.

#### $microseconds

CarbonInterval.php : 0
`public int $microseconds`

Total microseconds of the current interval.

#### $milliseconds

CarbonInterval.php : 0
`public int $milliseconds`

Total milliseconds of the current interval.

#### $minutes

CarbonInterval.php : 0
`public int $minutes`

Total minutes of the current interval.

#### $months

CarbonInterval.php : 0
`public int $months`

Total months of the current interval.

#### $seconds

CarbonInterval.php : 0
`public int $seconds`

Total seconds of the current interval.

#### $totalDays read-only

CarbonInterval.php : 0
`public float $totalDays`

Number of days equivalent to the interval.

#### $totalDayz read-only

CarbonInterval.php : 0
`public float $totalDayz`

Alias for totalDays.

#### $totalHours read-only

CarbonInterval.php : 0
`public float $totalHours`

Number of hours equivalent to the interval.

#### $totalMicroseconds read-only

CarbonInterval.php : 0
`public float $totalMicroseconds`

Number of microseconds equivalent to the interval.

#### $totalMilliseconds read-only

CarbonInterval.php : 0
`public float $totalMilliseconds`

Number of milliseconds equivalent to the interval.

#### $totalMinutes read-only

CarbonInterval.php : 0
`public float $totalMinutes`

Number of minutes equivalent to the interval.

#### $totalMonths read-only

CarbonInterval.php : 0
`public float $totalMonths`

Number of months equivalent to the interval.

#### $totalSeconds read-only

CarbonInterval.php : 0
`public float $totalSeconds`

Number of seconds equivalent to the interval.

#### $totalWeeks read-only

CarbonInterval.php : 0
`public float $totalWeeks`

Number of weeks equivalent to the interval.

#### $totalYears read-only

CarbonInterval.php : 0
`public float $totalYears`

Number of years equivalent to the interval.

#### $weeks

CarbonInterval.php : 0
`public int $weeks`

Total weeks of the current interval calculated from the days.

#### $years

CarbonInterval.php : 0
`public int $years`

Total years of the current interval.

#### $cascadeFactors

CarbonInterval.php : 241
`protected static array<string|int, mixed>|null $cascadeFactors = null`

#### $endDate

CarbonInterval.php : 290

End date if interval was created from a difference between 2 dates.

`protected CarbonInterface|null $endDate = null`

#### $formats

CarbonInterval.php : 243
`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

CarbonInterval.php : 297
`protected array<string|int, mixed>|null $initialValues = null`

#### $localFormatFunction

Options.php : 86

Function to call instead of format.

`protected string|callable|null $localFormatFunction = null`

#### $localGenericMacros

Options.php : 79

Instance-specific generic macros.

`protected array<string|int, mixed>|null $localGenericMacros = null`

#### $localHumanDiffOptions

Options.php : 55

Options for diffForHumans and forHumans methods.

`protected int|null $localHumanDiffOptions = null`

#### $localMacros

Options.php : 74

Instance-specific macros.

`protected array<string|int, mixed>|null $localMacros = null`

#### $localMonthsOverflow

Options.php : 38

Indicates if months should be calculated with overflow.

`protected bool|null $localMonthsOverflow = null`

Specific setting.

#### $localSerializer

Options.php : 69

Format to use on JSON serialization.

`protected string|callable|null $localSerializer = null`

#### $localStrictModeEnabled

Options.php : 50

Indicates if the strict mode is in use.

`protected bool|null $localStrictModeEnabled = null`

Specific setting.

#### $localToStringFormat

Options.php : 62

Format to use on string cast.

`protected string|callable|null $localToStringFormat = null`

#### $localYearsOverflow

Options.php : 44

Indicates if years should be calculated with overflow.

`protected bool|null $localYearsOverflow = null`

Specific setting.

#### $macroContextStack

Mixin.php : 36

Stack of macro instance contexts.

`protected static array<string|int, mixed> $macroContextStack = []`

#### $macros

CarbonInterval.php : 270

The registered macros.

`protected static array<string|int, mixed> $macros = []`

#### $originalInput

CarbonInterval.php : 280

The input used to create the interval.

`protected mixed $originalInput = null`

#### $rawInterval

CarbonInterval.php : 295

End date if interval was created from a difference between 2 dates.

`protected DateInterval|null $rawInterval = null`

#### $startDate

CarbonInterval.php : 285

Start date if interval was created from a difference between 2 dates.

`protected CarbonInterface|null $startDate = null`

#### $step

IntervalStep.php : 31

Step to apply instead of a fixed interval to get the new date.

`protected Closure|null $step`

#### $timezoneSetting

CarbonInterval.php : 275

Timezone handler for settings() method.

`protected DateTimeZone|string|int|null $timezoneSetting = null`

#### $clock

LocalFactory.php : 29

The clock that generated the current instance (or FactoryImmutable::getDefaultInstance() if none)

`private WrapperClock|null $clock = null`

#### $flipCascadeFactors

CarbonInterval.php : 263
`private static array<string|int, mixed>|null $flipCascadeFactors = null`

#### $floatSettersEnabled

CarbonInterval.php : 265
`private static bool $floatSettersEnabled = false`

### Methods

#### __call()

CarbonInterval.php : 1591

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

throws
  BadFluentSetterException|Throwable

##### Return values

static|int|float|string

#### __callStatic()

CarbonInterval.php : 833

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()

CarbonInterval.php : 415

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

throws
  Exception

  when the interval_spec (passed as $years) cannot be parsed as an interval.

#### __debugInfo()

Options.php : 174

Show truthy properties on var_dump().

`public __debugInfo() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### __get()

CarbonInterval.php : 1330

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()

CarbonInterval.php : 1452

Set a part of the CarbonInterval object.

`public __set(string $name, int $value) : mixed`

##### Parameters

$name : string
$value : int

##### Tags

throws
  UnknownSetterException

#### __set_state()

CarbonInterval.php : 865

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()

CarbonInterval.php : 2088

Format the instance as a string using the forHumans() function.

`public __toString() : string`

##### Tags

throws
  Exception

##### Return values

string

#### __unserialize()

CarbonInterval.php : 3048
`public __unserialize(array<string|int, mixed> $data) : void`

##### Parameters

$data : array<string|int, mixed>

#### abs()

CarbonInterval.php : 1122

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

$this

#### absolute()

CarbonInterval.php : 1140
`public absolute([bool $absolute = true ]) : $this`

##### Parameters

$absolute : bool = true

  do nothing if set to false

##### Tags

alias

  abs

  Invert the interval if it's inverted.

##### Return values

$this

#### add()

CarbonInterval.php : 2212

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

$this

#### addDays()

CarbonInterval.php : 0
`public addDays(int|float $days) : $this`

Add given number of days to the current interval

##### Parameters

$days : int|float

##### Return values

$this

#### addHours()

CarbonInterval.php : 0
`public addHours(int|float $hours) : $this`

Add given number of hours to the current interval

##### Parameters

$hours : int|float

##### Return values

$this

#### addMicroseconds()

CarbonInterval.php : 0
`public addMicroseconds(int|float $microseconds) : $this`

Add given number of microseconds to the current interval

##### Parameters

$microseconds : int|float

##### Return values

$this

#### addMilliseconds()

CarbonInterval.php : 0
`public addMilliseconds(int|float $milliseconds) : $this`

Add given number of milliseconds to the current interval

##### Parameters

$milliseconds : int|float

##### Return values

$this

#### addMinutes()

CarbonInterval.php : 0
`public addMinutes(int|float $minutes) : $this`

Add given number of minutes to the current interval

##### Parameters

$minutes : int|float

##### Return values

$this

#### addMonths()

CarbonInterval.php : 0
`public addMonths(int $months) : $this`

Add given number of months to the current interval

##### Parameters

$months : int

##### Return values

$this

#### addSeconds()

CarbonInterval.php : 0
`public addSeconds(int|float $seconds) : $this`

Add given number of seconds to the current interval

##### Parameters

$seconds : int|float

##### Return values

$this

#### addWeeks()

CarbonInterval.php : 0
`public addWeeks(int|float $weeks) : $this`

Add given number of weeks to the current interval

##### Parameters

$weeks : int|float

##### Return values

$this

#### addYears()

CarbonInterval.php : 0
`public addYears(int $years) : $this`

Add given number of years to the current interval

##### Parameters

$years : int

##### Return values

$this

#### between()

CarbonInterval.php : 2876

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

example

      CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::days(3)); // true
      CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::hours(36)); // false
      CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::days(2)); // true
      CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::days(2), false); // false

##### Return values

bool

#### betweenExcluded()

CarbonInterval.php : 2918

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

example

      CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::days(3)); // true
      CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::hours(36)); // false
      CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::days(2)); // false

##### Return values

bool

#### betweenIncluded()

CarbonInterval.php : 2898

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

example

      CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::days(3)); // true
      CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::hours(36)); // false
      CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::days(2)); // true

##### Return values

bool

#### cascade()

CarbonInterval.php : 2545

Convert overflowed values into bigger units.

`public cascade() : $this`

##### Return values

$this

#### cast()

CarbonInterval.php : 1154

Cast the current instance into the given class.

`public cast(string $className) : T`

##### Parameters

$className : string

##### Tags

template

  T of DateInterval

psalm-param

  class-string<T> $className The $className::instance() method will be called to cast the current object.

##### Return values

T

#### ceil()

CarbonInterval.php : 3043

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

throws
  Exception

##### Return values

$this

#### ceilCenturies()

CarbonInterval.php : 0
`public ceilCenturies(int|float $precision = 1) : $this`

Ceil the current instance century with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilCentury()

CarbonInterval.php : 0
`public ceilCentury(int|float $precision = 1) : $this`

Ceil the current instance century with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilDay()

CarbonInterval.php : 0
`public ceilDay(int|float $precision = 1) : $this`

Ceil the current instance day with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilDays()

CarbonInterval.php : 0
`public ceilDays(int|float $precision = 1) : $this`

Ceil the current instance day with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilDecade()

CarbonInterval.php : 0
`public ceilDecade(int|float $precision = 1) : $this`

Ceil the current instance decade with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilDecades()

CarbonInterval.php : 0
`public ceilDecades(int|float $precision = 1) : $this`

Ceil the current instance decade with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilHour()

CarbonInterval.php : 0
`public ceilHour(int|float $precision = 1) : $this`

Ceil the current instance hour with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilHours()

CarbonInterval.php : 0
`public ceilHours(int|float $precision = 1) : $this`

Ceil the current instance hour with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilMicrosecond()

CarbonInterval.php : 0
`public ceilMicrosecond(int|float $precision = 1) : $this`

Ceil the current instance microsecond with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilMicroseconds()

CarbonInterval.php : 0
`public ceilMicroseconds(int|float $precision = 1) : $this`

Ceil the current instance microsecond with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilMillennia()

CarbonInterval.php : 0
`public ceilMillennia(int|float $precision = 1) : $this`

Ceil the current instance millennium with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilMillennium()

CarbonInterval.php : 0
`public ceilMillennium(int|float $precision = 1) : $this`

Ceil the current instance millennium with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilMillisecond()

CarbonInterval.php : 0
`public ceilMillisecond(int|float $precision = 1) : $this`

Ceil the current instance millisecond with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilMilliseconds()

CarbonInterval.php : 0
`public ceilMilliseconds(int|float $precision = 1) : $this`

Ceil the current instance millisecond with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilMinute()

CarbonInterval.php : 0
`public ceilMinute(int|float $precision = 1) : $this`

Ceil the current instance minute with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilMinutes()

CarbonInterval.php : 0
`public ceilMinutes(int|float $precision = 1) : $this`

Ceil the current instance minute with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilMonth()

CarbonInterval.php : 0
`public ceilMonth(int|float $precision = 1) : $this`

Ceil the current instance month with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilMonths()

CarbonInterval.php : 0
`public ceilMonths(int|float $precision = 1) : $this`

Ceil the current instance month with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilQuarter()

CarbonInterval.php : 0
`public ceilQuarter(int|float $precision = 1) : $this`

Ceil the current instance quarter with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilQuarters()

CarbonInterval.php : 0
`public ceilQuarters(int|float $precision = 1) : $this`

Ceil the current instance quarter with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilSecond()

CarbonInterval.php : 0
`public ceilSecond(int|float $precision = 1) : $this`

Ceil the current instance second with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilSeconds()

CarbonInterval.php : 0
`public ceilSeconds(int|float $precision = 1) : $this`

Ceil the current instance second with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilUnit()

CarbonInterval.php : 3004

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

throws
  Exception

##### Return values

$this

#### ceilWeek()

CarbonInterval.php : 0
`public ceilWeek(int|float $precision = 1) : $this`

Ceil the current instance day with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilWeeks()

CarbonInterval.php : 0
`public ceilWeeks(int|float $precision = 1) : $this`

Ceil the current instance day with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilYear()

CarbonInterval.php : 0
`public ceilYear(int|float $precision = 1) : $this`

Ceil the current instance year with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### ceilYears()

CarbonInterval.php : 0
`public ceilYears(int|float $precision = 1) : $this`

Ceil the current instance year with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### clone()

CarbonInterval.php : 817

Get a copy of the instance.

`public clone() : static`

##### Return values

static

#### compare()

CarbonInterval.php : 2535

Comparing with passed interval.

`public compare(DateInterval $interval) : int`

##### Parameters

$interval : DateInterval

##### Return values

int —

0, 1 or -1

#### compareDateIntervals()

CarbonInterval.php : 2519

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()

IntervalStep.php : 65

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

CarbonInterface

#### copy()

CarbonInterval.php : 803

Get a copy of the instance.

`public copy() : static`

##### Return values

static

#### create()

CarbonInterval.php : 677

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

throws
  Exception

  when the interval_spec (passed as $years) cannot be parsed as an interval.

##### Return values

static

#### createFromDateString()

CarbonInterval.php : 1258

Sets up a DateInterval from the relative parts of the string.

`public static createFromDateString(string $datetime) : static`

##### Parameters

$datetime : string

##### Tags

link
  https://php.net/manual/en/dateinterval.createfromdatestring.php

##### Return values

static

#### createFromFormat()

CarbonInterval.php : 697

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

example

      echo Carboninterval::createFromFormat('H:i', '1:30');

throws
  ParseErrorException

  when the $interval cannot be parsed as an interval.

##### Return values

static

#### day()

CarbonInterval.php : 0
`public static day(mixed $days) : CarbonInterval`

Alias for days()

##### Parameters

$days : mixed

##### Return values

CarbonInterval

#### days()

CarbonInterval.php : 0
`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

CarbonInterval

#### daysExcludeWeeks()

CarbonInterval.php : 0
`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

CarbonInterval

#### dayz()

CarbonInterval.php : 0
`public static dayz(mixed $days) : CarbonInterval`

Alias for days()

##### Parameters

$days : mixed

##### Return values

CarbonInterval

#### dayzExcludeWeeks()

CarbonInterval.php : 0
`public static dayzExcludeWeeks(mixed $days) : CarbonInterval`

Alias for daysExcludeWeeks()

##### Parameters

$days : mixed

##### Return values

CarbonInterval

#### diff()

CarbonInterval.php : 1100

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

static

#### divide()

CarbonInterval.php : 2442

Divide and cascade current instance by a given divider.

`public divide(float|int $divider) : $this`

##### Parameters

$divider : float|int

##### Return values

$this

#### enableFloatSetters()

CarbonInterval.php : 392

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()

CarbonInterval.php : 776

Return the end date if interval was created from a difference between 2 dates.

`public end() : CarbonInterface|null`

##### Return values

CarbonInterface|null

#### eq()

CarbonInterval.php : 2684

Determines if the instance is equal to another

`public eq(CarbonInterval|DateInterval|mixed $interval) : bool`

##### Parameters

$interval : CarbonInterval|DateInterval|mixed

##### Tags

see
  equalTo()

##### Return values

bool

#### equalTo()

CarbonInterval.php : 2696

Determines if the instance is equal to another

`public equalTo(CarbonInterval|DateInterval|mixed $interval) : bool`

##### Parameters

$interval : CarbonInterval|DateInterval|mixed

##### Return values

bool

#### floor()

CarbonInterval.php : 3031

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

throws
  Exception

##### Return values

$this

#### floorCenturies()

CarbonInterval.php : 0
`public floorCenturies(int|float $precision = 1) : $this`

Truncate the current instance century with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorCentury()

CarbonInterval.php : 0
`public floorCentury(int|float $precision = 1) : $this`

Truncate the current instance century with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorDay()

CarbonInterval.php : 0
`public floorDay(int|float $precision = 1) : $this`

Truncate the current instance day with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorDays()

CarbonInterval.php : 0
`public floorDays(int|float $precision = 1) : $this`

Truncate the current instance day with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorDecade()

CarbonInterval.php : 0
`public floorDecade(int|float $precision = 1) : $this`

Truncate the current instance decade with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorDecades()

CarbonInterval.php : 0
`public floorDecades(int|float $precision = 1) : $this`

Truncate the current instance decade with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorHour()

CarbonInterval.php : 0
`public floorHour(int|float $precision = 1) : $this`

Truncate the current instance hour with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorHours()

CarbonInterval.php : 0
`public floorHours(int|float $precision = 1) : $this`

Truncate the current instance hour with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorMicrosecond()

CarbonInterval.php : 0
`public floorMicrosecond(int|float $precision = 1) : $this`

Truncate the current instance microsecond with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorMicroseconds()

CarbonInterval.php : 0
`public floorMicroseconds(int|float $precision = 1) : $this`

Truncate the current instance microsecond with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorMillennia()

CarbonInterval.php : 0
`public floorMillennia(int|float $precision = 1) : $this`

Truncate the current instance millennium with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorMillennium()

CarbonInterval.php : 0
`public floorMillennium(int|float $precision = 1) : $this`

Truncate the current instance millennium with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorMillisecond()

CarbonInterval.php : 0
`public floorMillisecond(int|float $precision = 1) : $this`

Truncate the current instance millisecond with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorMilliseconds()

CarbonInterval.php : 0
`public floorMilliseconds(int|float $precision = 1) : $this`

Truncate the current instance millisecond with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorMinute()

CarbonInterval.php : 0
`public floorMinute(int|float $precision = 1) : $this`

Truncate the current instance minute with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorMinutes()

CarbonInterval.php : 0
`public floorMinutes(int|float $precision = 1) : $this`

Truncate the current instance minute with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorMonth()

CarbonInterval.php : 0
`public floorMonth(int|float $precision = 1) : $this`

Truncate the current instance month with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorMonths()

CarbonInterval.php : 0
`public floorMonths(int|float $precision = 1) : $this`

Truncate the current instance month with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorQuarter()

CarbonInterval.php : 0
`public floorQuarter(int|float $precision = 1) : $this`

Truncate the current instance quarter with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorQuarters()

CarbonInterval.php : 0
`public floorQuarters(int|float $precision = 1) : $this`

Truncate the current instance quarter with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorSecond()

CarbonInterval.php : 0
`public floorSecond(int|float $precision = 1) : $this`

Truncate the current instance second with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorSeconds()

CarbonInterval.php : 0
`public floorSeconds(int|float $precision = 1) : $this`

Truncate the current instance second with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorUnit()

CarbonInterval.php : 2989

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

throws
  Exception

##### Return values

$this

#### floorWeek()

CarbonInterval.php : 0
`public floorWeek(int|float $precision = 1) : $this`

Truncate the current instance day with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorWeeks()

CarbonInterval.php : 0
`public floorWeeks(int|float $precision = 1) : $this`

Truncate the current instance day with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorYear()

CarbonInterval.php : 0
`public floorYear(int|float $precision = 1) : $this`

Truncate the current instance year with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### floorYears()

CarbonInterval.php : 0
`public floorYears(int|float $precision = 1) : $this`

Truncate the current instance year with given precision.

##### Parameters

$precision = 1 : int|float

##### Return values

$this

#### forHumans()

CarbonInterval.php : 1867

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

example

      echo CarbonInterval::fromString('4d 3h 40m')->forHumans() . "\n";
      echo CarbonInterval::fromString('4d 3h 40m')->forHumans(['parts' => 2]) . "\n";
      echo CarbonInterval::fromString('4d 3h 40m')->forHumans(['parts' => 3, 'join' => true]) . "\n";
      echo CarbonInterval::fromString('4d 3h 40m')->forHumans(['short' => true]) . "\n";
      echo CarbonInterval::fromString('1d 24h')->forHumans(['join' => ' or ']) . "\n";
      echo CarbonInterval::fromString('1d 24h')->forHumans(['minimumUnit' => 'hour']) . "\n";

throws
  Exception

##### Return values

string

#### format()

CarbonInterval.php : 2068
`public format(string $format) : string`

##### Parameters

$format : string

##### Return values

string

#### fromString()

CarbonInterval.php : 913

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

throws
  InvalidIntervalException

##### Return values

static

#### get()

CarbonInterval.php : 1292

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|null

#### getCascadeFactors()

CarbonInterval.php : 354

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()

LocalFactory.php : 31
`public getClock() : WrapperClock|null`

##### Return values

WrapperClock|null

#### getDateIntervalSpec()

CarbonInterval.php : 2454

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

string

#### getDaysPerWeek()

CarbonInterval.php : 603

Returns current config for days per week.

`public static getDaysPerWeek() : int|float`

##### Return values

int|float

#### getFactor()

CarbonInterval.php : 548

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|null

#### getFactorWithDefault()

CarbonInterval.php : 576

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|null

#### getHoursPerDay()

CarbonInterval.php : 613

Returns current config for hours per day.

`public static getHoursPerDay() : int|float`

##### Return values

int|float

#### getMicrosecondsPerMillisecond()

CarbonInterval.php : 653

Returns current config for microseconds per second.

`public static getMicrosecondsPerMillisecond() : int|float`

##### Return values

int|float

#### getMillisecondsPerSecond()

CarbonInterval.php : 643

Returns current config for microseconds per second.

`public static getMillisecondsPerSecond() : int|float`

##### Return values

int|float

#### getMinutesPerHour()

CarbonInterval.php : 623

Returns current config for minutes per hour.

`public static getMinutesPerHour() : int|float`

##### Return values

int|float

#### getNonZeroValues()

CarbonInterval.php : 1775

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()

CarbonInterval.php : 633

Returns current config for seconds per minute.

`public static getSecondsPerMinute() : int|float`

##### Return values

int|float

#### getSettings()

Options.php : 143

Returns current local settings.

`public getSettings() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### getStep()

IntervalStep.php : 38

Get the dynamic step in use.

`public getStep() : Closure`

##### Return values

Closure

#### getValuesSequence()

CarbonInterval.php : 1786

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()

CarbonInterval.php : 2768

Determines if the instance is greater (longer) than another

`public greaterThan(CarbonInterval|DateInterval|mixed $interval) : bool`

##### Parameters

$interval : CarbonInterval|DateInterval|mixed

##### Return values

bool

#### greaterThanOrEqualTo()

CarbonInterval.php : 2796

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

bool

#### gt()

CarbonInterval.php : 2756

Determines if the instance is greater (longer) than another

`public gt(CarbonInterval|DateInterval|mixed $interval) : bool`

##### Parameters

$interval : CarbonInterval|DateInterval|mixed

##### Tags

see
  greaterThan()

##### Return values

bool

#### gte()

CarbonInterval.php : 2784

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

see
  greaterThanOrEqualTo()

##### Return values

bool

#### hasMacro()

CarbonInterval.php : 1552

Check if macro is registered.

`public static hasMacro(string $name) : bool`

##### Parameters

$name : string

##### Return values

bool

#### hasNegativeValues()

CarbonInterval.php : 2550
`public hasNegativeValues() : bool`

##### Return values

bool

#### hasPositiveValues()

CarbonInterval.php : 2561
`public hasPositiveValues() : bool`

##### Return values

bool

#### hour()

CarbonInterval.php : 0
`public static hour(mixed $hours) : CarbonInterval`

Alias for hours()

##### Parameters

$hours : mixed

##### Return values

CarbonInterval

#### hours()

CarbonInterval.php : 0
`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

CarbonInterval

#### instance()

CarbonInterval.php : 1171

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

static

#### invert()

CarbonInterval.php : 2181

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

$this

#### isBetween()

CarbonInterval.php : 2940

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

example

      CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::days(3)); // true
      CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::hours(36)); // false
      CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::days(2)); // true
      CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::days(2), false); // false

##### Return values

bool

#### isEmpty()

CarbonInterval.php : 1477

Returns true if the interval is empty for each unit.

`public isEmpty() : bool`

##### Return values

bool

#### lessThan()

CarbonInterval.php : 2822

Determines if the instance is less (shorter) than another

`public lessThan(CarbonInterval|DateInterval|mixed $interval) : bool`

##### Parameters

$interval : CarbonInterval|DateInterval|mixed

##### Return values

bool

#### lessThanOrEqualTo()

CarbonInterval.php : 2850

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

bool

#### lt()

CarbonInterval.php : 2810

Determines if the instance is less (shorter) than another

`public lt(CarbonInterval|DateInterval|mixed $interval) : bool`

##### Parameters

$interval : CarbonInterval|DateInterval|mixed

##### Tags

see
  lessThan()

##### Return values

bool

#### lte()

CarbonInterval.php : 2838

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

see
  lessThanOrEqualTo()

##### Return values

bool

#### macro()

CarbonInterval.php : 1502

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

example

      CarbonInterval::macro('twice', function () {
        return $this->times(2);
      });
      echo CarbonInterval::hours(2)->twice();

#### make()

CarbonInterval.php : 1194

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|null

#### microsecond()

CarbonInterval.php : 0
`public static microsecond(mixed $microseconds) : CarbonInterval`

Alias for microseconds()

##### Parameters

$microseconds : mixed

##### Return values

CarbonInterval

#### microseconds()

CarbonInterval.php : 0
`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

CarbonInterval

#### millisecond()

CarbonInterval.php : 0
`public static millisecond(mixed $milliseconds) : CarbonInterval`

Alias for milliseconds()

##### Parameters

$milliseconds : mixed

##### Return values

CarbonInterval

#### milliseconds()

CarbonInterval.php : 0
`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

CarbonInterval

#### minus()

CarbonInterval.php : 2321

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

$this

#### minute()

CarbonInterval.php : 0
`public static minute(mixed $minutes) : CarbonInterval`

Alias for minutes()

##### Parameters

$minutes : mixed

##### Return values

CarbonInterval

#### minutes()

CarbonInterval.php : 0
`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

CarbonInterval

#### mixin()

CarbonInterval.php : 1540

Register macros from a mixin object.

`public static mixin(object|string $mixin) : void`

##### Parameters

$mixin : object|string

##### Tags

example

      CarbonInterval::mixin(new class {
        public function daysToHours() {
          return function () {
            $this->hours += $this->days;
            $this->days = 0;

            return $this;
          };
        }
        public function hoursToDays() {
          return function () {
            $this->days += $this->hours;
            $this->hours = 0;

            return $this;
          };
        }
      });
      echo CarbonInterval::hours(5)->hoursToDays() . "\n";
      echo CarbonInterval::days(5)->daysToHours() . "\n";

throws
  ReflectionException

#### month()

CarbonInterval.php : 0
`public static month(mixed $months) : CarbonInterval`

Alias for months()

##### Parameters

$months : mixed

##### Return values

CarbonInterval

#### months()

CarbonInterval.php : 0
`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

CarbonInterval

#### multiply()

CarbonInterval.php : 2414

Multiply and cascade current instance by a given factor.

`public multiply(float|int $factor) : $this`

##### Parameters

$factor : float|int

##### Return values

$this

#### ne()

CarbonInterval.php : 2730

Determines if the instance is not equal to another

`public ne(CarbonInterval|DateInterval|mixed $interval) : bool`

##### Parameters

$interval : CarbonInterval|DateInterval|mixed

##### Tags

see
  notEqualTo()

##### Return values

bool

#### notEqualTo()

CarbonInterval.php : 2742

Determines if the instance is not equal to another

`public notEqualTo(CarbonInterval|DateInterval|mixed $interval) : bool`

##### Parameters

$interval : CarbonInterval|DateInterval|mixed

##### Return values

bool

#### optimize()

CarbonInterval.php : 788

Get rid of the original input, start date and end date that may be kept in memory.

`public optimize() : $this`

##### Return values

$this

#### original()

CarbonInterval.php : 754

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|null

#### parseFromLocale()

CarbonInterval.php : 1087

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

static

#### plus()

CarbonInterval.php : 2291

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

$this

#### resetToStringFormat()

ToStringFormat.php : 31

Reset the format used to the default when type juggling a Carbon instance to a string

`public static resetToStringFormat() : void`

#### round()

CarbonInterval.php : 3019

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

throws
  Exception

##### Return values

$this

#### roundCenturies()

CarbonInterval.php : 0
`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

$this

#### roundCentury()

CarbonInterval.php : 0
`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

$this

#### roundDay()

CarbonInterval.php : 0
`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

$this

#### roundDays()

CarbonInterval.php : 0
`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

$this

#### roundDecade()

CarbonInterval.php : 0
`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

$this

#### roundDecades()

CarbonInterval.php : 0
`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

$this

#### roundHour()

CarbonInterval.php : 0
`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

$this

#### roundHours()

CarbonInterval.php : 0
`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

$this

#### roundMicrosecond()

CarbonInterval.php : 0
`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

$this

#### roundMicroseconds()

CarbonInterval.php : 0
`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

$this

#### roundMillennia()

CarbonInterval.php : 0
`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

$this

#### roundMillennium()

CarbonInterval.php : 0
`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

$this

#### roundMillisecond()

CarbonInterval.php : 0
`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

$this

#### roundMilliseconds()

CarbonInterval.php : 0
`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

$this

#### roundMinute()

CarbonInterval.php : 0
`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

$this

#### roundMinutes()

CarbonInterval.php : 0
`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

$this

#### roundMonth()

CarbonInterval.php : 0
`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

$this

#### roundMonths()

CarbonInterval.php : 0
`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

$this

#### roundQuarter()

CarbonInterval.php : 0
`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

$this

#### roundQuarters()

CarbonInterval.php : 0
`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

$this

#### roundSecond()

CarbonInterval.php : 0
`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

$this

#### roundSeconds()

CarbonInterval.php : 0
`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

$this

#### roundUnit()

CarbonInterval.php : 2950

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

throws
  Exception

##### Return values

static

#### roundWeek()

CarbonInterval.php : 0
`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

$this

#### roundWeeks()

CarbonInterval.php : 0
`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

$this

#### roundYear()

CarbonInterval.php : 0
`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

$this

#### roundYears()

CarbonInterval.php : 0
`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

$this

#### second()

CarbonInterval.php : 0
`public static second(mixed $seconds) : CarbonInterval`

Alias for seconds()

##### Parameters

$seconds : mixed

##### Return values

CarbonInterval

#### seconds()

CarbonInterval.php : 0
`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

CarbonInterval

#### set()

CarbonInterval.php : 1345

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

throws
  UnknownSetterException

##### Return values

$this

#### setCascadeFactors()

CarbonInterval.php : 378

Set default cascading factors for ->cascade() method.

`public static setCascadeFactors(array<string|int, mixed> $cascadeFactors) : mixed`

##### Parameters

$cascadeFactors : array<string|int, mixed>

#### setStep()

IntervalStep.php : 50

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()

CarbonInterval.php : 302

Set the instance's timezone from a string or object.

`public setTimezone(DateTimeZone|string|int $timezone) : static`

##### Parameters

$timezone : DateTimeZone|string|int

##### Return values

static

#### settings()

Options.php : 105

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|static

#### setToStringFormat()

ToStringFormat.php : 48
`public static setToStringFormat(string|Closure|null $format) : void`

##### Parameters

$format : string|Closure|null

##### Tags

deprecated

  To avoid conflict between different third-party libraries, static setters should not be used. You should rather let Carbon object being cast to string with DEFAULT_TO_STRING_FORMAT, and use other method or custom format passed to format() method if you need to dump another string format.

  Set the default format used when type juggling a Carbon instance to a string.

#### shares()

CarbonInterval.php : 2385

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

see
  divide()

##### Return values

$this

#### shiftTimezone()

CarbonInterval.php : 327

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

static

#### spec()

CarbonInterval.php : 2506

Get the interval_spec string.

`public spec([bool $microseconds = false ]) : string`

##### Parameters

$microseconds : bool = false

##### Return values

string

#### start()

CarbonInterval.php : 764

Return the start date if interval was created from a difference between 2 dates.

`public start() : CarbonInterface|null`

##### Return values

CarbonInterface|null

#### stepBy()

CarbonInterval.php : 2152

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

CarbonPeriod

#### sub()

CarbonInterval.php : 2255

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

$this

#### subDays()

CarbonInterval.php : 0
`public subDays(int|float $days) : $this`

Subtract given number of days to the current interval

##### Parameters

$days : int|float

##### Return values

$this

#### subHours()

CarbonInterval.php : 0
`public subHours(int|float $hours) : $this`

Subtract given number of hours to the current interval

##### Parameters

$hours : int|float

##### Return values

$this

#### subMicroseconds()

CarbonInterval.php : 0
`public subMicroseconds(int|float $microseconds) : $this`

Subtract given number of microseconds to the current interval

##### Parameters

$microseconds : int|float

##### Return values

$this

#### subMilliseconds()

CarbonInterval.php : 0
`public subMilliseconds(int|float $milliseconds) : $this`

Subtract given number of milliseconds to the current interval

##### Parameters

$milliseconds : int|float

##### Return values

$this

#### subMinutes()

CarbonInterval.php : 0
`public subMinutes(int|float $minutes) : $this`

Subtract given number of minutes to the current interval

##### Parameters

$minutes : int|float

##### Return values

$this

#### subMonths()

CarbonInterval.php : 0
`public subMonths(int $months) : $this`

Subtract given number of months to the current interval

##### Parameters

$months : int

##### Return values

$this

#### subSeconds()

CarbonInterval.php : 0
`public subSeconds(int|float $seconds) : $this`

Subtract given number of seconds to the current interval

##### Parameters

$seconds : int|float

##### Return values

$this

#### subtract()

CarbonInterval.php : 2272

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

$this

#### subWeeks()

CarbonInterval.php : 0
`public subWeeks(int|float $weeks) : $this`

Subtract given number of weeks to the current interval

##### Parameters

$weeks : int|float

##### Return values

$this

#### subYears()

CarbonInterval.php : 0
`public subYears(int $years) : $this`

Subtract given number of years to the current interval

##### Parameters

$years : int

##### Return values

$this

#### times()

CarbonInterval.php : 2352

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

see
  multiply()

##### Return values

$this

#### toArray()

CarbonInterval.php : 1756

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()

CarbonInterval.php : 2115

Return native DateInterval PHP object matching the current instance.

`public toDateInterval() : DateInterval`

##### Tags

example

      var_dump(CarbonInterval::hours(2)->toDateInterval());

##### Return values

DateInterval

#### toPeriod()

CarbonInterval.php : 2127

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

CarbonPeriod

#### total()

CarbonInterval.php : 2581

Get amount of given unit equivalent to the interval.

`public total(string $unit) : float`

##### Parameters

$unit : string

##### Tags

throws
  UnknownUnitException|UnitNotConfiguredException

##### Return values

float

#### week()

CarbonInterval.php : 0
`public static week(mixed $weeks) : CarbonInterval`

Alias for weeks()

##### Parameters

$weeks : mixed

##### Return values

CarbonInterval

#### weeks()

CarbonInterval.php : 0
`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

CarbonInterval

#### weeksAndDays()

CarbonInterval.php : 1465

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

static

#### year()

CarbonInterval.php : 0
`public static year(mixed $years) : CarbonInterval`

Alias for years()

##### Parameters

$years : mixed

##### Return values

CarbonInterval

#### years()

CarbonInterval.php : 0
`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

CarbonInterval

#### addExtraDebugInfos()

Options.php : 202
`protected addExtraDebugInfos(array<string|int, mixed> &$infos) : void`

##### Parameters

$infos : array<string|int, mixed>

#### bindMacroContext()

Mixin.php : 182

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()

CarbonInterval.php : 1565

Call given macro.

`protected callMacro(string $name, array<string|int, mixed> $parameters) : mixed`

##### Parameters

$name : string
$parameters : array<string|int, mixed>

#### callRoundMethod()

IntervalRounding.php : 25
`protected callRoundMethod(string $method, array<string|int, mixed> $parameters) : static|null`

##### Parameters

$method : string
$parameters : array<string|int, mixed>

##### Return values

static|null

#### context()

Mixin.php : 196

Return the current context from inside a macro callee or a null if static.

`protected static context() : static|null`

##### Return values

static|null

#### copyProperties()

CarbonInterval.php : 2390
`protected copyProperties(self $interval[, mixed $ignoreSign = false ]) : static`

##### Parameters

$interval : self
$ignoreSign : mixed = false

##### Return values

static

#### getDefaultCascadeFactors()

CarbonInterval.php : 359
`protected static getDefaultCascadeFactors() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### getForHumansInitialVariables()

CarbonInterval.php : 1624
`protected getForHumansInitialVariables(mixed $syntax, mixed $short) : array<string|int, mixed>`

##### Parameters

$syntax : mixed
$short : mixed

##### Return values

array<string|int, mixed>

#### getForHumansParameters()

CarbonInterval.php : 1655
`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()

CarbonInterval.php : 1734
`protected static getRoundingMethodFromOptions(int $options) : string|null`

##### Parameters

$options : int

##### Return values

string|null

#### isLocalStrictModeEnabled()

Options.php : 196
`protected isLocalStrictModeEnabled() : bool`

##### Return values

bool

#### makeFromString()

CarbonInterval.php : 1223
`protected static makeFromString(string $interval) : self|null`

##### Parameters

$interval : string

##### Return values

self|null

#### resolveInterval()

CarbonInterval.php : 1240
`protected resolveInterval(mixed $interval) : self|null`

##### Parameters

$interval : mixed

##### Return values

self|null

#### roundWith()

IntervalRounding.php : 40
`protected roundWith(DateInterval|string|float|int $precision, callable|string $function) : static|null`

##### Parameters

$precision : DateInterval|string|float|int
$function : callable|string

##### Return values

static|null

#### solveNegativeInterval()

CarbonInterval.php : 2188
`protected solveNegativeInterval() : static`

##### Return values

static

#### this()

CarbonInterval.php : 880

Return the current context from inside a macro callee or a new one if static.

`protected static this() : static`

##### Return values

static

#### assertSafeForInteger()

CarbonInterval.php : 3282

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()

CarbonInterval.php : 3128
`private static castIntervalToClass(DateInterval $interval, string $className[, array<string|int, mixed> $skip = [] ]) : T`

##### Parameters

$interval : DateInterval
$className : string
$skip : array<string|int, mixed> = []

##### Tags

template

  T of DateInterval

psalm-param

  class-string<T> $className

##### Return values

T

#### checkIntegerValue()

CarbonInterval.php : 3254
`private checkIntegerValue(string $name, mixed $value) : void`

##### Parameters

$name : string
$value : mixed

#### checkStartAndEnd()

CarbonInterval.php : 3333
`private checkStartAndEnd() : void`

#### copyNegativeUnits()

CarbonInterval.php : 3161
`private static copyNegativeUnits(DateInterval $from, DateInterval $to) : void`

##### Parameters

$from : DateInterval
$to : DateInterval

#### copyStep()

CarbonInterval.php : 3156
`private static copyStep(self $from, self $to) : void`

##### Parameters

$from : self
$to : self

#### doCascade()

CarbonInterval.php : 3179
`private doCascade(bool $deep) : static`

##### Parameters

$deep : bool

##### Return values

static

#### getAnonymousClassCodeForTrait()

Mixin.php : 163
`private static getAnonymousClassCodeForTrait(string $trait) : string`

##### Parameters

$trait : string

##### Return values

string

#### getFactory()

LocalFactory.php : 63
`private getFactory() : Factory`

##### Return values

Factory

#### getFlipCascadeFactors()

CarbonInterval.php : 3106
`private static getFlipCascadeFactors() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### getInnerValues()

CarbonInterval.php : 3328
`private getInnerValues() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### getMagicParameter()

MagicParameter.php : 23
`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()

Mixin.php : 168
`private static getMixableMethods(self $context) : Generator`

##### Parameters

$context : self

##### Return values

Generator

#### handleDecimalPart()

CarbonInterval.php : 3289
`private handleDecimalPart(string $unit, mixed $value, mixed $integerValue) : void`

##### Parameters

$unit : string
$value : mixed
$integerValue : mixed

#### initLocalFactory()

LocalFactory.php : 36
`private initLocalFactory() : void`

#### invertCascade()

CarbonInterval.php : 3172
`private invertCascade(array<string|int, mixed> $values) : static`

##### Parameters

$values : array<string|int, mixed>

##### Return values

static

#### loadMixinClass()

Mixin.php : 75
`private static loadMixinClass(object|string $mixin) : void`

##### Parameters

$mixin : object|string

##### Tags

throws
  ReflectionException

#### loadMixinTrait()

Mixin.php : 94
`private static loadMixinTrait(string $trait) : void`

##### Parameters

$trait : string

#### needsDeclension()

CarbonInterval.php : 3246
`private needsDeclension(string $mode, int $index, int $parts) : bool`

##### Parameters

$mode : string
$index : int
$parts : int

##### Return values

bool

#### resolveCarbon()

IntervalStep.php : 86

Convert DateTimeImmutable instance to CarbonImmutable instance and DateTime instance to Carbon instance.

`private resolveCarbon(DateTimeInterface $dateTime) : Carbon|CarbonImmutable`

##### Parameters

$dateTime : DateTimeInterface

##### Return values

Carbon|CarbonImmutable

#### setSetting()

CarbonInterval.php : 3347
`private setSetting(string $setting, mixed $value) : $this`

##### Parameters

$setting : string
$value : mixed

##### Return values

$this

#### standardizeUnit()

CarbonInterval.php : 3099
`private static standardizeUnit(string $unit) : string`

##### Parameters

$unit : string

##### Return values

string

#### transmitFactory()

LocalFactory.php : 51

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

template

  T

##### Return values

T

#### withOriginal()

CarbonInterval.php : 3090
`private static withOriginal(T $interval, mixed $original) : T`

##### Parameters

$interval : T
$original : mixed

##### Tags

template

  T

##### Return values

T

## Search results