Carbon::isMutable

no arguments
returns bool

Returns true if the current class/instance is mutable.

Method added2.0.0no arguments

Carbon::__construct

DateTimeInterface|Carbon\WeekDay|Carbon\Month|string|int|float|null $time = null, DateTimeZone|string|int|null $timezone = null

Create a new Carbon instance.

Please see the testing aids section (specifically static::setTestNow()) for more on the possibility of this constructor returning a test instance.

Prototype changed3.0.0DateTimeInterface|Carbon\WeekDay|Carbon\Month|string|int|float|null $time = null, DateTimeZone|string|int|null $timezone = null
Method added1.0.0$time = null, $tz = null

Carbon::__serialize

no arguments
returns array

Returns the values to dump on serialize() called on.

Only used by PHP >= 7.4.

Method added1.37.1no arguments

Carbon::__unserialize

array $data

Set locale if specified on unserialize() called.

Only used by PHP >= 7.4.

Method added1.37.1array $data

Carbon::__wakeup

no arguments

Set locale if specified on unserialize() called.

Only used by PHP < 7.4.

Method added1.0.0no arguments

Carbon::__set_state

$dump
returns Carbon

The __set_state handler.

Prototype changed2.0.0$dump
Prototype changed1.24.2$array
Prototype changed1.24.1$state
Prototype changed1.24.0array $state
Prototype changed1.23.0$array
Method added1.0.0array $array

Carbon::createFromImmutable

Native PHP method

See PHP documentation for DateTime::createFromImmutable

Carbon::createFromInterface

Native PHP method
returns DateTime

See PHP documentation for DateTime::createFromInterface

Carbon::createFromFormat

$format, $time, $timezone = null
returns Carbon

Create a Carbon instance from a specific format.

Prototype changed3.0.0$format, $time, $timezone = null
Prototype changed1.3.0$format, $time, $tz = null
Method added1.0.0$format, $time, $object = null

Carbon::getLastErrors

no arguments
returns array|false

{@inheritdoc}

Method added1.0.0no arguments

Carbon::format

string $format
returns string

Returns the formatted date string on success or FALSE on failure.

Prototype changed3.0.0string $format
Prototype changed2.16.0$format
Prototype changed1.37.1string $format
Method added1.0.0$format

Carbon::modify

$modify
returns Carbon

Calls \DateTime::modify if mutable or \DateTimeImmutable::modify else.

Prototype changed2.23.0$modify
Prototype changed1.37.1string $modifier
Method added1.0.0$modify

Carbon::add

$unit, $value = 1, ?bool $overflow = null
returns Carbon

Add given units or interval to the current instance.

Examples:

$date->add('hour', 3)

$date->add(15, 'days')

$date->add(CarbonInterval::days(4))

Prototype changed3.0.0$unit, $value = 1, ?bool $overflow = null
Prototype changed2.0.0$unit, $value = 1, $overflow = null
Prototype changed1.37.1DateInterval $interval
Method added1.0.0$interval

Carbon::sub

$unit, $value = 1, ?bool $overflow = null
returns Carbon

Subtract given units or interval to the current instance.

Examples:

$date->sub('hour', 3)

$date->sub(15, 'days')

$date->sub(CarbonInterval::days(4))

Prototype changed3.0.0$unit, $value = 1, ?bool $overflow = null
Prototype changed2.0.0$unit, $value = 1, $overflow = null
Prototype changed1.37.1DateInterval $interval
Method added1.0.0$interval

Carbon::getTimezone

no arguments
returns CarbonTimeZone

Get the TimeZone associated with the Carbon instance (as CarbonTimeZone).

Method added1.0.0no arguments

Carbon::setTimezone

DateTimeZone|string|int $timeZone
returns Carbon

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

Prototype changed3.0.0DateTimeZone|string|int $timeZone
Method added1.0.0$value

Carbon::getOffset

Native PHP method

See PHP documentation for DateTime::getOffset

Carbon::setTime

int $hour, int $minute, int $second = 0, int $microseconds = 0
returns Carbon

Resets the current time of the DateTime object to a different time.

Prototype changed3.0.0int $hour, int $minute, int $second = 0, int $microseconds = 0
Prototype changed2.23.0$hour, $minute, $second = 0, $microseconds = 0
Prototype changed1.37.1int $hour, int $minute, int $second = 0, int $microsecond = 0
Prototype changed1.15.0$hour, $minute, $second, $microseconds
Method added1.0.0$hour, $minute, $second = 0

Carbon::setDate

int $year, int $month, int $day
returns Carbon

Set the date with gregorian year, month and day numbers.

Prototype changed3.0.0int $year, int $month, int $day
Prototype changed2.23.0$year, $month, $day
Prototype changed2.0.0int $year, int $month, int $day
Method added1.0.0$year, $month, $day

Carbon::setISODate

int $year, int $week, int $day = 1
returns Carbon

Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.

Prototype changed3.0.0int $year, int $week, int $day = 1
Prototype changed2.23.0$year, $week, $day = 1
Prototype changed1.37.1int $year, int $week, int $dayOfWeek = 1
Method added1.0.0$year, $week, $day

Carbon::setTimestamp

string|int|float $timestamp
returns Carbon

Set the instance's timestamp.

Timestamp input can be given as int, float or a string containing one or more numbers.

Prototype changed3.0.0string|int|float $timestamp
Prototype changed2.41.0$unixTimestamp
Prototype changed2.23.0$unixtimestamp
Prototype changed1.37.1int $timestamp
Method added1.0.0$unixtimestamp

Carbon::getTimestamp

Native PHP method

See PHP documentation for DateTime::getTimestamp

Carbon::diff

$date = null, bool $absolute = false, array $skip = []
returns CarbonInterval

@alias diffAsCarbonInterval

Get the difference as a DateInterval instance. Return relative interval (negative if $absolute flag is not set to true and the given date is before current one).

Prototype changed3.0.0$date = null, bool $absolute = false, array $skip = []
Prototype changed2.23.0$date = null, $absolute = false
Prototype changed1.37.1DateTimeInterface $targetObject, bool $absolute = false
Method added1.0.0$object, $absolute

Carbon::copy

no arguments
returns Carbon

Get a copy of the instance.

Method added1.0.0no arguments

Carbon::clone

no arguments
returns Carbon

@alias copy

Get a copy of the instance.

Method added2.0.0no arguments

Carbon::avoidMutation

no arguments
returns Carbon

Clone the current instance if it's mutable.

This method is convenient to ensure you don't mutate the initial object but avoid to make a useless copy of it if it's already immutable.

Method added2.50.0no arguments

Carbon::nowWithSameTz

no arguments
returns Carbon

Returns a present instance in the same timezone.

Method added1.24.0no arguments

Carbon::carbonize

$date = null
returns Carbon

Return the Carbon instance passed through, a now instance in the same timezone if null given or parse the input if string given.

Method added2.23.0$date = null

Carbon::__get

string $name
returns mixed

Get a part of the Carbon object.

Prototype changed3.0.0string $name
Method added1.0.0$name

Carbon::get

Carbon\Unit|string $name
returns mixed

Get a part of the Carbon object.

Prototype changed3.1.0Carbon\Unit|string $name
Prototype changed3.0.0string $name
Method added2.0.0$name

Carbon::__isset

$name
returns bool

Check if an attribute exists on the object

Method added1.2.0$name

Carbon::__set

$name, $value

Set a part of the Carbon object

Method added1.0.0$name, $value

Carbon::set

Carbon\Unit|array|string $name, DateTimeZone|Carbon\Month|string|int|float|null $value = null
returns Carbon

Set a part of the Carbon object.

Prototype changed3.1.0Carbon\Unit|array|string $name, DateTimeZone|Carbon\Month|string|int|float|null $value = null
Prototype changed3.0.0array|string $name, DateTimeZone|Carbon\Month|string|int|float|null $value = null
Method added2.0.0$name, $value = null

Carbon::getTranslatedDayName

?string $context = null, string $keySuffix = '', ?string $defaultValue = null
returns string

Get the translation of the current week day name (with context for languages with multiple forms).

Prototype changed3.0.0?string $context = null, string $keySuffix = '', ?string $defaultValue = null
Method added2.4.0$context = null, $keySuffix = '', $defaultValue = null

Carbon::getTranslatedShortDayName

?string $context = null
returns string

Get the translation of the current short week day name (with context for languages with multiple forms).

Prototype changed3.0.0?string $context = null
Method added2.4.0$context = null

Carbon::getTranslatedMinDayName

?string $context = null
returns string

Get the translation of the current abbreviated week day name (with context for languages with multiple forms).

Prototype changed3.0.0?string $context = null
Method added2.4.0$context = null

Carbon::getTranslatedMonthName

?string $context = null, string $keySuffix = '', ?string $defaultValue = null
returns string

Get the translation of the current month day name (with context for languages with multiple forms).

Prototype changed3.0.0?string $context = null, string $keySuffix = '', ?string $defaultValue = null
Method added2.4.0$context = null, $keySuffix = '', $defaultValue = null

Carbon::getTranslatedShortMonthName

?string $context = null
returns string

Get the translation of the current short month day name (with context for languages with multiple forms).

Prototype changed3.0.0?string $context = null
Method added2.4.0$context = null

Carbon::dayOfYear

?int $value = null
returns Carbon|int

Get/set the day of year.

Prototype changed3.0.0?int $value = null
Method added2.0.0$value = null

Carbon::weekday

Carbon\WeekDay|int|null $value = null
returns Carbon|int

Get/set the weekday from 0 (Sunday) to 6 (Saturday).

Prototype changed3.0.0Carbon\WeekDay|int|null $value = null
Method added2.0.0$value = null

Carbon::isoWeekday

Carbon\WeekDay|int|null $value = null
returns Carbon|int

Get/set the ISO weekday from 1 (Monday) to 7 (Sunday).

Prototype changed3.0.0Carbon\WeekDay|int|null $value = null
Method added2.0.0$value = null

Carbon::getDaysFromStartOfWeek

Carbon\WeekDay|int|null $weekStartsAt = null
returns int

Return the number of days since the start of the week (using the current locale or the first parameter if explicitly given).

Prototype changed3.0.0Carbon\WeekDay|int|null $weekStartsAt = null
Method added2.64.0?int $weekStartsAt = null

Carbon::setDaysFromStartOfWeek

int $numberOfDays, Carbon\WeekDay|int|null $weekStartsAt = null
returns Carbon

Set the day (keeping the current time) to the start of the week + the number of days passed as the first parameter. First day of week is driven by the locale unless explicitly set with the second parameter.

Prototype changed3.0.0int $numberOfDays, Carbon\WeekDay|int|null $weekStartsAt = null
Method added2.64.0int $numberOfDays, ?int $weekStartsAt = null

Carbon::setUnitNoOverflow

string $valueUnit, int $value, string $overflowUnit
returns Carbon

Set any unit to a new value without overflowing current other unit given.

Prototype changed3.0.0string $valueUnit, int $value, string $overflowUnit
Method added2.0.0$valueUnit, $value, $overflowUnit

Carbon::addUnitNoOverflow

string $valueUnit, int $value, string $overflowUnit
returns Carbon

Add any unit to a new value without overflowing current other unit given.

Prototype changed3.0.0string $valueUnit, int $value, string $overflowUnit
Method added2.0.0$valueUnit, $value, $overflowUnit

Carbon::subUnitNoOverflow

string $valueUnit, int $value, string $overflowUnit
returns Carbon

Subtract any unit to a new value without overflowing current other unit given.

Prototype changed3.0.0string $valueUnit, int $value, string $overflowUnit
Method added2.0.0$valueUnit, $value, $overflowUnit

Carbon::utcOffset

?int $minuteOffset = null
returns Carbon|int

Returns the minutes offset to UTC if no arguments passed, else set the timezone with given minutes shift passed.

Prototype changed2.44.0?int $minuteOffset = null
Method added2.0.0?int $offset = null

Carbon::setDateTime

int $year, int $month, int $day, int $hour, int $minute, int $second = 0, int $microseconds = 0
returns Carbon

Set the date and time all together.

Prototype changed3.0.0int $year, int $month, int $day, int $hour, int $minute, int $second = 0, int $microseconds = 0
Prototype changed2.0.0$year, $month, $day, $hour, $minute, $second = 0, $microseconds = 0
Prototype changed1.12.0$year, $month, $day, $hour, $minute, $second = 0
Method added1.0.0$year, $month, $day, $hour, $minute, $second

Carbon::setTimeFromTimeString

string $time
returns Carbon

Set the time by time string.

Prototype changed3.0.0string $time
Method added1.21.0$time

Carbon::timezone

DateTimeZone|string|int $value
returns Carbon

@alias setTimezone

Prototype changed3.0.0DateTimeZone|string|int $value
Method added1.0.0$value

Carbon::tz

DateTimeZone|string|int|null $value = null
returns Carbon|string

Set the timezone or returns the timezone name if no arguments passed.

Prototype changed3.0.0DateTimeZone|string|int|null $value = null
Prototype changed2.0.0$value = null
Method added1.0.0$value

Carbon::shiftTimezone

DateTimeZone|string $value
returns Carbon

Set the instance's timezone from a string or object and add/subtract the offset difference.

Prototype changed3.0.0DateTimeZone|string $value
Method added2.0.0$value

Carbon::utc

no arguments
returns Carbon

Set the instance's timezone to UTC.

Method added2.0.0no arguments

Carbon::setDateFrom

DateTimeInterface|string $date
returns Carbon

Set the year, month, and date for this instance to that of the passed instance.

Prototype changed3.0.0DateTimeInterface|string $date
Prototype changed2.0.0$date = null
Method added1.26.0$date

Carbon::setTimeFrom

DateTimeInterface|string $date
returns Carbon

Set the hour, minute, second and microseconds for this instance to that of the passed instance.

Prototype changed3.0.0DateTimeInterface|string $date
Prototype changed2.0.0$date = null
Method added1.26.0$date

Carbon::setDateTimeFrom

DateTimeInterface|string $date
returns Carbon

Set the date and time for this instance to that of the passed instance.

Prototype changed3.0.0DateTimeInterface|string $date
Method added2.0.0$date = null

Carbon::getDays

no arguments
returns array

Get the days of the week.

Method added1.23.0no arguments

Carbon::getWeekStartsAt

?string $locale = null
returns int

Get the first day of week.

Prototype changed3.0.0?string $locale = null
Method added1.20.0no arguments

Carbon::getWeekEndsAt

?string $locale = null
returns int

Get the last day of week.

Prototype changed3.0.0?string $locale = null
Method added1.20.0no arguments

Carbon::getWeekendDays

no arguments
returns array

Get weekend days

Method added1.20.0no arguments

Carbon::setWeekendDays

array $days

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather consider week-end is always saturday and sunday, and if you have some custom week-end days to handle, give to those days an other name and create a macro for them:

Set weekend days

Examples:

Carbon::macro('isDayOff', function ($date) {
    return $date->isSunday() || $date->isMonday();
});
Carbon::macro('isNotDayOff', function ($date) {
    return !$date->isDayOff();
});
if ($someDate->isDayOff()) ...
if ($someDate->isNotDayOff()) ...
// Add 5 not-off days
$count = 5;
while ($someDate->isDayOff() || ($count-- > 0)) {
    $someDate->addDay();
}

Prototype changed3.0.0array $days
Method added1.20.0$days

Carbon::hasRelativeKeywords

?string $time
returns bool

Determine if a time string will produce a relative date.

Prototype changed3.0.0?string $time
Method added1.4.0$time

Carbon::getIsoFormats

?string $locale = null
returns array

Returns list of locale formats for ISO formatting.

Prototype changed3.0.0?string $locale = null
Method added2.0.0$locale = null

Carbon::getCalendarFormats

?string $locale = null
returns array

Returns list of calendar formats for ISO formatting.

Prototype changed3.0.0?string $locale = null
Method added2.0.0$locale = null

Carbon::getIsoUnits

no arguments
returns array

Returns list of locale units for ISO formatting.

Method added2.0.0no arguments

Carbon::getPaddedUnit

$unit, $length = 2, $padString = '0', $padType = 0
returns string

Returns a unit of the instance padded with 0 by default or any other string if specified.

Method added2.0.0$unit, $length = 2, $padString = '0', $padType = 0

Carbon::ordinal

string $key, ?string $period = null
returns string

Return a property with its ordinal.

Method added2.0.0string $key, ?string $period = null

Carbon::meridiem

bool $isLower = false
returns string

Return the meridiem of the current time in the current locale.

Method added2.14.0bool $isLower = false

Carbon::getAltNumber

string $key
returns string

Returns the alternative number for a given date property if available in the current locale.

Method added2.14.0string $key

Carbon::isoFormat

string $format, ?string $originalFormat = null
returns string

Format in the current language using ISO replacement patterns.

Prototype changed2.16.0string $format, ?string $originalFormat = null
Method added2.0.0string $format

Carbon::getFormatsToIsoReplacements

no arguments
returns array

List of replacements from date() format to isoFormat().

Method added2.16.0no arguments

Carbon::translatedFormat

string $format
returns string

Format as ->format() do (using date replacements patterns from https://php.net/manual/en/function.date.php) but translate words whenever possible (months, day names, etc.) using the current locale.

Method added2.16.0string $format

Carbon::getOffsetString

string $separator = ':'
returns string

Returns the offset hour and minute formatted with +/- and a given separator (":" by default). For example, if the time zone is 9 hours 30 minutes, you'll get "+09:30", with "@@" as first argument, "+09@@30", with "" as first argument, "+0930". Negative offset will return something like "-12:00".

Prototype changed3.0.0string $separator = ':'
Method added2.0.0$separator = ':'

Carbon::setUnit

string $unit, Carbon\Month|int|float|null $value = null
returns Carbon

Set specified unit to new given value.

Prototype changed3.0.0string $unit, Carbon\Month|int|float|null $value = null
Method added2.0.0$unit, $value = null

Carbon::singularUnit

string $unit
returns string

Returns standardized singular of a given singular/plural unit name (in English).

Method added2.0.0string $unit

Carbon::pluralUnit

string $unit
returns string

Returns standardized plural of a given singular/plural unit name (in English).

Method added2.0.0string $unit

Carbon::sleep

int|float $seconds

Method added3.0.0int|float $seconds

Carbon::startOfDay

no arguments
returns Carbon

Resets the time to 00:00:00 start of day

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->startOfDay();

Method added1.0.0no arguments

Carbon::endOfDay

no arguments
returns Carbon

Resets the time to 23:59:59.999999 end of day

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->endOfDay();

Method added1.0.0no arguments

Carbon::startOfMonth

no arguments
returns Carbon

Resets the date to the first day of the month and the time to 00:00:00

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->startOfMonth();

Method added1.0.0no arguments

Carbon::endOfMonth

no arguments
returns Carbon

Resets the date to end of the month and time to 23:59:59.999999

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->endOfMonth();

Method added1.0.0no arguments

Carbon::startOfQuarter

no arguments
returns Carbon

Resets the date to the first day of the quarter and the time to 00:00:00

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->startOfQuarter();

Method added1.22.0no arguments

Carbon::endOfQuarter

no arguments
returns Carbon

Resets the date to end of the quarter and time to 23:59:59.999999

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->endOfQuarter();

Method added1.22.0no arguments

Carbon::startOfYear

no arguments
returns Carbon

Resets the date to the first day of the year and the time to 00:00:00

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->startOfYear();

Method added1.7.0no arguments

Carbon::endOfYear

no arguments
returns Carbon

Resets the date to end of the year and time to 23:59:59.999999

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->endOfYear();

Method added1.7.0no arguments

Carbon::startOfDecade

no arguments
returns Carbon

Resets the date to the first day of the decade and the time to 00:00:00

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->startOfDecade();

Method added1.7.0no arguments

Carbon::endOfDecade

no arguments
returns Carbon

Resets the date to end of the decade and time to 23:59:59.999999

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->endOfDecade();

Method added1.7.0no arguments

Carbon::startOfCentury

no arguments
returns Carbon

Resets the date to the first day of the century and the time to 00:00:00

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->startOfCentury();

Method added1.7.0no arguments

Carbon::endOfCentury

no arguments
returns Carbon

Resets the date to end of the century and time to 23:59:59.999999

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->endOfCentury();

Method added1.7.0no arguments

Carbon::startOfMillennium

no arguments
returns Carbon

Resets the date to the first day of the millennium and the time to 00:00:00

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->startOfMillennium();

Method added1.39.0no arguments

Carbon::endOfMillennium

no arguments
returns Carbon

Resets the date to end of the millennium and time to 23:59:59.999999

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->endOfMillennium();

Method added1.39.0no arguments

Carbon::startOfWeek

Carbon\WeekDay|int|null $weekStartsAt = null
returns Carbon

Resets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->startOfWeek() . "\n";
echo Carbon::parse('2018-07-25 12:45:16')->locale('ar')->startOfWeek() . "\n";
echo Carbon::parse('2018-07-25 12:45:16')->startOfWeek(Carbon::SUNDAY) . "\n";

Prototype changed3.0.0Carbon\WeekDay|int|null $weekStartsAt = null
Prototype changed2.0.0$weekStartsAt = null
Method added1.3.0no arguments

Carbon::endOfWeek

Carbon\WeekDay|int|null $weekEndsAt = null
returns Carbon

Resets the date to end of week (defined in $weekEndsAt) and time to 23:59:59.999999

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->endOfWeek() . "\n";
echo Carbon::parse('2018-07-25 12:45:16')->locale('ar')->endOfWeek() . "\n";
echo Carbon::parse('2018-07-25 12:45:16')->endOfWeek(Carbon::SATURDAY) . "\n";

Prototype changed3.0.0Carbon\WeekDay|int|null $weekEndsAt = null
Prototype changed2.0.0$weekEndsAt = null
Method added1.3.0no arguments

Carbon::startOfHour

no arguments
returns Carbon

Modify to start of current hour, minutes and seconds become 0

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->startOfHour();

Method added1.24.0no arguments

Carbon::endOfHour

no arguments
returns Carbon

Modify to end of current hour, minutes and seconds become 59

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->endOfHour();

Method added1.24.0no arguments

Carbon::startOfMinute

no arguments
returns Carbon

Modify to start of current minute, seconds become 0

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->startOfMinute();

Method added1.24.0no arguments

Carbon::endOfMinute

no arguments
returns Carbon

Modify to end of current minute, seconds become 59

Examples:

echo Carbon::parse('2018-07-25 12:45:16')->endOfMinute();

Method added1.24.0no arguments

Carbon::startOfSecond

no arguments
returns Carbon

Modify to start of current second, microseconds become 0

Examples:

echo Carbon::parse('2018-07-25 12:45:16.334455')
  ->startOfSecond()
  ->format('H:i:s.u');

Method added1.33.0no arguments

Carbon::endOfSecond

no arguments
returns Carbon

Modify to end of current second, microseconds become 999999

Examples:

echo Carbon::parse('2018-07-25 12:45:16.334455')
  ->endOfSecond()
  ->format('H:i:s.u');

Method added1.33.0no arguments

Carbon::startOf

string $unit, mixed $params
returns Carbon

Modify to start of current given unit.

Examples:

echo Carbon::parse('2018-07-25 12:45:16.334455')
  ->startOf('month')
  ->endOf('week', Carbon::FRIDAY);

Prototype changed3.0.0string $unit, mixed $params
Method added2.0.0$unit, $params

Carbon::endOf

string $unit, mixed $params
returns Carbon

Modify to end of current given unit.

Examples:

echo Carbon::parse('2018-07-25 12:45:16.334455')
  ->startOf('month')
  ->endOf('week', Carbon::FRIDAY);

Prototype changed3.0.0string $unit, mixed $params
Method added2.0.0$unit, $params

Carbon::eq

DateTimeInterface|string $date
returns bool

Determines if the instance is equal to another

Examples:

Carbon::parse('2018-07-25 12:45:16')->eq('2018-07-25 12:45:16'); // true
Carbon::parse('2018-07-25 12:45:16')->eq(Carbon::parse('2018-07-25 12:45:16')); // true
Carbon::parse('2018-07-25 12:45:16')->eq('2018-07-25 12:45:17'); // false

Prototype changed3.0.0DateTimeInterface|string $date
Prototype changed1.24.0$date
Prototype changed1.23.0self $date
Method added1.0.0Carbon\Carbon $date

Carbon::equalTo

DateTimeInterface|string $date
returns bool

Determines if the instance is equal to another

Examples:

Carbon::parse('2018-07-25 12:45:16')->equalTo('2018-07-25 12:45:16'); // true
Carbon::parse('2018-07-25 12:45:16')->equalTo(Carbon::parse('2018-07-25 12:45:16')); // true
Carbon::parse('2018-07-25 12:45:16')->equalTo('2018-07-25 12:45:17'); // false

Prototype changed3.0.0DateTimeInterface|string $date
Prototype changed1.24.0$date
Prototype changed1.23.0self $date
Method added1.22.0Carbon\Carbon $date

Carbon::ne

DateTimeInterface|string $date
returns bool

Determines if the instance is not equal to another

Examples:

Carbon::parse('2018-07-25 12:45:16')->ne('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->ne(Carbon::parse('2018-07-25 12:45:16')); // false
Carbon::parse('2018-07-25 12:45:16')->ne('2018-07-25 12:45:17'); // true

Prototype changed3.0.0DateTimeInterface|string $date
Prototype changed1.24.0$date
Prototype changed1.23.0self $date
Method added1.0.0Carbon\Carbon $date

Carbon::notEqualTo

DateTimeInterface|string $date
returns bool

Determines if the instance is not equal to another

Examples:

Carbon::parse('2018-07-25 12:45:16')->notEqualTo('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->notEqualTo(Carbon::parse('2018-07-25 12:45:16')); // false
Carbon::parse('2018-07-25 12:45:16')->notEqualTo('2018-07-25 12:45:17'); // true

Prototype changed3.0.0DateTimeInterface|string $date
Prototype changed1.24.0$date
Prototype changed1.23.0self $date
Method added1.22.0Carbon\Carbon $date

Carbon::gt

DateTimeInterface|string $date
returns bool

Determines if the instance is greater (after) than another

Examples:

Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:15'); // true
Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:17'); // false

Prototype changed3.0.0DateTimeInterface|string $date
Prototype changed1.24.0$date
Prototype changed1.23.0self $date
Method added1.0.0Carbon\Carbon $date

Carbon::greaterThan

DateTimeInterface|string $date
returns bool

Determines if the instance is greater (after) than another

Examples:

Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:15'); // true
Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:17'); // false

Prototype changed3.0.0DateTimeInterface|string $date
Prototype changed1.24.0$date
Prototype changed1.23.0self $date
Method added1.22.0Carbon\Carbon $date

Carbon::isAfter

DateTimeInterface|string $date
returns bool

Determines if the instance is greater (after) than another

Examples:

Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:15'); // true
Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:17'); // false

Prototype changed3.0.0DateTimeInterface|string $date
Method added1.39.0$date

Carbon::gte

DateTimeInterface|string $date
returns bool

Determines if the instance is greater (after) than or equal to another

Examples:

Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:15'); // true
Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:16'); // true
Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:17'); // false

Prototype changed3.0.0DateTimeInterface|string $date
Prototype changed1.24.0$date
Prototype changed1.23.0self $date
Method added1.0.0Carbon\Carbon $date

Carbon::greaterThanOrEqualTo

DateTimeInterface|string $date
returns bool

Determines if the instance is greater (after) than or equal to another

Examples:

Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:15'); // true
Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:16'); // true
Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:17'); // false

Prototype changed3.0.0DateTimeInterface|string $date
Prototype changed1.24.0$date
Prototype changed1.23.0self $date
Method added1.22.0Carbon\Carbon $date

Carbon::lt

DateTimeInterface|string $date
returns bool

Determines if the instance is less (before) than another

Examples:

Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:15'); // false
Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:17'); // true

Prototype changed3.0.0DateTimeInterface|string $date
Prototype changed1.24.0$date
Prototype changed1.23.0self $date
Method added1.0.0Carbon\Carbon $date

Carbon::lessThan

DateTimeInterface|string $date
returns bool

Determines if the instance is less (before) than another

Examples:

Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:15'); // false
Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:17'); // true

Prototype changed3.0.0DateTimeInterface|string $date
Prototype changed1.24.0$date
Prototype changed1.23.0self $date
Method added1.22.0Carbon\Carbon $date

Carbon::isBefore

DateTimeInterface|string $date
returns bool

Determines if the instance is less (before) than another

Examples:

Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:15'); // false
Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:17'); // true

Prototype changed3.0.0DateTimeInterface|string $date
Method added1.39.0$date

Carbon::lte

DateTimeInterface|string $date
returns bool

Determines if the instance is less (before) or equal to another

Examples:

Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:15'); // false
Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:16'); // true
Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:17'); // true

Prototype changed3.0.0DateTimeInterface|string $date
Prototype changed1.24.0$date
Prototype changed1.23.0self $date
Method added1.0.0Carbon\Carbon $date

Carbon::lessThanOrEqualTo

DateTimeInterface|string $date
returns bool

Determines if the instance is less (before) or equal to another

Examples:

Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:15'); // false
Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:16'); // true
Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:17'); // true

Prototype changed3.0.0DateTimeInterface|string $date
Prototype changed1.24.0$date
Prototype changed1.23.0self $date
Method added1.22.0Carbon\Carbon $date

Carbon::between

DateTimeInterface|string $date1, DateTimeInterface|string $date2, bool $equal = true
returns bool

Determines if the instance is between two others.

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.

Examples:

Carbon::parse('2018-07-25')->between('2018-07-14', '2018-08-01'); // true
Carbon::parse('2018-07-25')->between('2018-08-01', '2018-08-20'); // false
Carbon::parse('2018-07-25')->between('2018-07-25', '2018-08-01'); // true
Carbon::parse('2018-07-25')->between('2018-07-25', '2018-08-01', false); // false

Prototype changed3.0.0DateTimeInterface|string $date1, DateTimeInterface|string $date2, bool $equal = true
Prototype changed1.24.0$date1, $date2, $equal = true
Prototype changed1.23.0self $dt1, self $dt2, $equal = true
Method added1.3.0Carbon\Carbon $dt1, Carbon\Carbon $dt2, $equal = true

Carbon::betweenIncluded

DateTimeInterface|string $date1, DateTimeInterface|string $date2
returns bool

Determines if the instance is between two others, bounds included.

Examples:

Carbon::parse('2018-07-25')->betweenIncluded('2018-07-14', '2018-08-01'); // true
Carbon::parse('2018-07-25')->betweenIncluded('2018-08-01', '2018-08-20'); // false
Carbon::parse('2018-07-25')->betweenIncluded('2018-07-25', '2018-08-01'); // true

Prototype changed3.0.0DateTimeInterface|string $date1, DateTimeInterface|string $date2
Method added2.31.0$date1, $date2

Carbon::betweenExcluded

DateTimeInterface|string $date1, DateTimeInterface|string $date2
returns bool

Determines if the instance is between two others, bounds excluded.

Examples:

Carbon::parse('2018-07-25')->betweenExcluded('2018-07-14', '2018-08-01'); // true
Carbon::parse('2018-07-25')->betweenExcluded('2018-08-01', '2018-08-20'); // false
Carbon::parse('2018-07-25')->betweenExcluded('2018-07-25', '2018-08-01'); // false

Prototype changed3.0.0DateTimeInterface|string $date1, DateTimeInterface|string $date2
Method added2.22.0$date1, $date2

Carbon::isBetween

DateTimeInterface|string $date1, DateTimeInterface|string $date2, bool $equal = true
returns bool

Determines if the instance is between two others

Examples:

Carbon::parse('2018-07-25')->isBetween('2018-07-14', '2018-08-01'); // true
Carbon::parse('2018-07-25')->isBetween('2018-08-01', '2018-08-20'); // false
Carbon::parse('2018-07-25')->isBetween('2018-07-25', '2018-08-01'); // true
Carbon::parse('2018-07-25')->isBetween('2018-07-25', '2018-08-01', false); // false

Prototype changed3.0.0DateTimeInterface|string $date1, DateTimeInterface|string $date2, bool $equal = true
Method added1.39.0$date1, $date2, $equal = true

Carbon::isWeekday

no arguments
returns bool

Determines if the instance is a weekday.

Examples:

Carbon::parse('2019-07-14')->isWeekday(); // false
Carbon::parse('2019-07-15')->isWeekday(); // true

Method added1.0.0no arguments

Carbon::isWeekend

no arguments
returns bool

Determines if the instance is a weekend day.

Examples:

Carbon::parse('2019-07-14')->isWeekend(); // true
Carbon::parse('2019-07-15')->isWeekend(); // false

Method added1.0.0no arguments

Carbon::isYesterday

no arguments
returns bool

Determines if the instance is yesterday.

Examples:

Carbon::yesterday()->isYesterday(); // true
Carbon::tomorrow()->isYesterday(); // false

Method added1.0.0no arguments

Carbon::isToday

no arguments
returns bool

Determines if the instance is today.

Examples:

Carbon::today()->isToday(); // true
Carbon::tomorrow()->isToday(); // false

Method added1.0.0no arguments

Carbon::isTomorrow

no arguments
returns bool

Determines if the instance is tomorrow.

Examples:

Carbon::tomorrow()->isTomorrow(); // true
Carbon::yesterday()->isTomorrow(); // false

Method added1.0.0no arguments

Carbon::isFuture

no arguments
returns bool

Determines if the instance is in the future, ie. greater (after) than now.

Examples:

Carbon::now()->addHours(5)->isFuture(); // true
Carbon::now()->subHours(5)->isFuture(); // false

Method added1.0.0no arguments

Carbon::isPast

no arguments
returns bool

Determines if the instance is in the past, ie. less (before) than now.

Examples:

Carbon::now()->subHours(5)->isPast(); // true
Carbon::now()->addHours(5)->isPast(); // false

Method added1.0.0no arguments

Carbon::isLeapYear

no arguments
returns bool

Determines if the instance is a leap year.

Examples:

Carbon::parse('2020-01-01')->isLeapYear(); // true
Carbon::parse('2019-01-01')->isLeapYear(); // false

Method added1.0.0no arguments

Carbon::isLongYear

no arguments
returns bool

Determines if the instance is a long year (using calendar year).

⚠️ This method completely ignores month and day to use the numeric year number, it's not correct if the exact date matters. For instance as `2019-12-30` is already in the first week of the 2020 year, if you want to know from this date if ISO week year 2020 is a long year, use `isLongIsoYear` instead.

Examples:

Carbon::create(2015)->isLongYear(); // true
Carbon::create(2016)->isLongYear(); // false

Method added1.22.0no arguments

Carbon::isLongIsoYear

no arguments
returns bool

Determines if the instance is a long year (using ISO 8601 year).

Examples:

Carbon::parse('2015-01-01')->isLongIsoYear(); // true
Carbon::parse('2016-01-01')->isLongIsoYear(); // true
Carbon::parse('2016-01-03')->isLongIsoYear(); // false
Carbon::parse('2019-12-29')->isLongIsoYear(); // false
Carbon::parse('2019-12-30')->isLongIsoYear(); // true

Method added2.65.0no arguments

Carbon::isSameAs

string $format, DateTimeInterface|string $date
returns bool

Compares the formatted values of the two dates.

Examples:

Carbon::parse('2019-06-13')->isSameAs('Y-d', Carbon::parse('2019-12-13')); // true
Carbon::parse('2019-06-13')->isSameAs('Y-d', Carbon::parse('2019-06-14')); // false

Prototype changed3.0.0string $format, DateTimeInterface|string $date
Prototype changed1.23.0$format, $date = null
Method added1.22.0$format, Carbon\Carbon $date = null

Carbon::isSameUnit

string $unit, DateTimeInterface|string $date
returns bool

Determines if the instance is in the current unit given.

Examples:

Carbon::parse('2019-01-13')->isSameUnit('year', Carbon::parse('2019-12-25')); // true
Carbon::parse('2018-12-13')->isSameUnit('year', Carbon::parse('2019-12-25')); // false

Prototype changed3.0.0string $unit, DateTimeInterface|string $date
Method added2.0.0$unit, $date = null

Carbon::isCurrentUnit

string $unit
returns bool

Determines if the instance is in the current unit given.

Examples:

Carbon::now()->isCurrentUnit('hour'); // true
Carbon::now()->subHours(2)->isCurrentUnit('hour'); // false

Prototype changed3.0.0string $unit
Method added2.0.0$unit

Carbon::isSameQuarter

DateTimeInterface|string $date, bool $ofSameYear = true
returns bool

Checks if the passed in date is in the same quarter as the instance quarter (and year if needed).

Examples:

Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2019-03-01')); // true
Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2019-04-01')); // false
Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2018-03-01')); // false
Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2018-03-01'), false); // true

Prototype changed3.0.0DateTimeInterface|string $date, bool $ofSameYear = true
Prototype changed2.0.0$date = null, $ofSameYear = true
Prototype changed1.29.2$date = null, $ofSameYear = null
Method added1.26.4$date = null, $ofSameYear = false

Carbon::isSameMonth

DateTimeInterface|string $date, bool $ofSameYear = true
returns bool

Checks if the passed in date is in the same month as the instance´s month.

Examples:

Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2019-01-01')); // true
Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2019-02-01')); // false
Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2018-01-01')); // false
Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2018-01-01'), false); // true

Prototype changed3.0.0DateTimeInterface|string $date, bool $ofSameYear = true
Prototype changed2.0.0$date = null, $ofSameYear = true
Prototype changed1.29.2$date = null, $ofSameYear = null
Prototype changed1.23.0$date = null, $ofSameYear = false
Method added1.22.0Carbon\Carbon $date = null, $ofSameYear = false

Carbon::isDayOfWeek

$dayOfWeek
returns bool

Checks if this day is a specific day of the week.

Examples:

Carbon::parse('2019-07-17')->isDayOfWeek(Carbon::WEDNESDAY); // true
Carbon::parse('2019-07-17')->isDayOfWeek(Carbon::FRIDAY); // false
Carbon::parse('2019-07-17')->isDayOfWeek('Wednesday'); // true
Carbon::parse('2019-07-17')->isDayOfWeek('Friday'); // false

Method added1.24.0$dayOfWeek

Carbon::isBirthday

DateTimeInterface|string|null $date = null
returns bool

Check if its the birthday. Compares the date/month values of the two dates.

Examples:

Carbon::now()->subYears(5)->isBirthday(); // true
Carbon::now()->subYears(5)->subDay()->isBirthday(); // false
Carbon::parse('2019-06-05')->isBirthday(Carbon::parse('2001-06-05')); // true
Carbon::parse('2019-06-05')->isBirthday(Carbon::parse('2001-06-06')); // false

Prototype changed3.0.0DateTimeInterface|string|null $date = null
Prototype changed1.23.0$date = null
Prototype changed1.21.0Carbon\Carbon $date = null
Method added1.14.0Carbon\Carbon $date

Carbon::isLastOfMonth

no arguments
returns bool

Check if today is the last day of the Month

Examples:

Carbon::parse('2019-02-28')->isLastOfMonth(); // true
Carbon::parse('2019-03-28')->isLastOfMonth(); // false
Carbon::parse('2019-03-30')->isLastOfMonth(); // false
Carbon::parse('2019-03-31')->isLastOfMonth(); // true
Carbon::parse('2019-04-30')->isLastOfMonth(); // true

Method added1.24.0no arguments

Carbon::isStartOfDay

bool $checkMicroseconds = false
returns bool

Check if the instance is start of day / midnight.

Examples:

Carbon::parse('2019-02-28 00:00:00')->isStartOfDay(); // true
Carbon::parse('2019-02-28 00:00:00.999999')->isStartOfDay(); // true
Carbon::parse('2019-02-28 00:00:01')->isStartOfDay(); // false
Carbon::parse('2019-02-28 00:00:00.000000')->isStartOfDay(true); // true
Carbon::parse('2019-02-28 00:00:00.000012')->isStartOfDay(true); // false

Prototype changed3.0.0bool $checkMicroseconds = false
Method added1.28.0$checkMicroseconds = false

Carbon::isEndOfDay

bool $checkMicroseconds = false
returns bool

Check if the instance is end of day.

Examples:

Carbon::parse('2019-02-28 23:59:59.999999')->isEndOfDay(); // true
Carbon::parse('2019-02-28 23:59:59.123456')->isEndOfDay(); // true
Carbon::parse('2019-02-28 23:59:59')->isEndOfDay(); // true
Carbon::parse('2019-02-28 23:59:58.999999')->isEndOfDay(); // false
Carbon::parse('2019-02-28 23:59:59.999999')->isEndOfDay(true); // true
Carbon::parse('2019-02-28 23:59:59.123456')->isEndOfDay(true); // false
Carbon::parse('2019-02-28 23:59:59')->isEndOfDay(true); // false

Prototype changed3.0.0bool $checkMicroseconds = false
Method added1.28.0$checkMicroseconds = false

Carbon::isMidnight

no arguments
returns bool

Check if the instance is start of day / midnight.

Examples:

Carbon::parse('2019-02-28 00:00:00')->isMidnight(); // true
Carbon::parse('2019-02-28 00:00:00.999999')->isMidnight(); // true
Carbon::parse('2019-02-28 00:00:01')->isMidnight(); // false

Method added1.28.0no arguments

Carbon::isMidday

no arguments
returns bool

Check if the instance is midday.

Examples:

Carbon::parse('2019-02-28 11:59:59.999999')->isMidday(); // false
Carbon::parse('2019-02-28 12:00:00')->isMidday(); // true
Carbon::parse('2019-02-28 12:00:00.999999')->isMidday(); // true
Carbon::parse('2019-02-28 12:00:01')->isMidday(); // false

Method added1.28.0no arguments

Carbon::hasFormat

string $date, string $format
returns bool

Checks if the (date)time string is in a given format.

Examples:

Carbon::hasFormat('11:12:45', 'h:i:s'); // true
Carbon::hasFormat('13:12:45', 'h:i:s'); // false

Prototype changed3.0.0string $date, string $format
Method added1.24.0$date, $format

Carbon::hasFormatWithModifiers

?string $date, string $format
returns bool

Checks if the (date)time string is in a given format.

Examples:

Carbon::hasFormatWithModifiers('31/08/2015', 'd#m#Y'); // true
Carbon::hasFormatWithModifiers('31/08/2015', 'm#d#Y'); // false

Prototype changed3.0.0?string $date, string $format
Prototype changed2.41.2$date, $format
Method added2.41.0string $date, string $format

Carbon::canBeCreatedFromFormat

?string $date, string $format
returns bool

Checks if the (date)time string is in a given format and valid to create a new instance.

Examples:

Carbon::canBeCreatedFromFormat('11:12:45', 'h:i:s'); // true
Carbon::canBeCreatedFromFormat('13:12:45', 'h:i:s'); // false

Prototype changed3.0.0?string $date, string $format
Method added2.39.1$date, $format

Carbon::is

string $tester
returns bool

Returns true if the current date matches the given string.

Examples:

\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2018')); // false
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019-06')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('06-02')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019-06-02')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('Sunday')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('June')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23:45')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23:00')); // false
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12h')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 15:23:45')->is('3pm')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 15:23:45')->is('3am')); // false

Method added2.20.0string $tester

Carbon::isStartOfTime

no arguments
returns bool

Returns true if the date was created using CarbonImmutable::startOfTime()

Method added2.48.0no arguments

Carbon::isEndOfTime

no arguments
returns bool

Returns true if the date was created using CarbonImmutable::endOfTime()

Method added2.48.0no arguments

Carbon::rawFormat

string $format
returns string

See php.net/manual/en/datetime.format.php

Prototype changed3.0.0string $format
Method added2.16.0$format

Carbon::__toString

no arguments
returns string

Format the instance as a string using the set format

Examples:

echo Carbon::now(); // Carbon instances can be cast to string

Method added1.0.0no arguments

Carbon::toDateString

no arguments
returns string

Format the instance as date

Examples:

echo Carbon::now()->toDateString();

Method added1.0.0no arguments

Carbon::toFormattedDateString

no arguments
returns string

Format the instance as a readable date

Examples:

echo Carbon::now()->toFormattedDateString();

Method added1.0.0no arguments

Carbon::toFormattedDayDateString

no arguments
returns string

Format the instance with the day, and a readable date

Examples:

echo Carbon::now()->toFormattedDayDateString();

Method added2.62.0no arguments

Carbon::toTimeString

string $unitPrecision = 'second'
returns string

Format the instance as time

Examples:

echo Carbon::now()->toTimeString();

Prototype changed3.0.0string $unitPrecision = 'second'
Prototype changed2.26.0$unitPrecision = 'second'
Method added1.0.0no arguments

Carbon::toDateTimeString

string $unitPrecision = 'second'
returns string

Format the instance as date and time

Examples:

echo Carbon::now()->toDateTimeString();

Prototype changed3.0.0string $unitPrecision = 'second'
Prototype changed2.26.0$unitPrecision = 'second'
Method added1.0.0no arguments

Carbon::getTimeFormatByPrecision

string $unitPrecision
returns string

Return a format from H:i to H:i:s.u according to given unit precision.

Prototype changed3.0.0string $unitPrecision
Method added2.26.0$unitPrecision

Carbon::toDateTimeLocalString

string $unitPrecision = 'second'
returns string

Format the instance as date and time T-separated with no timezone

Examples:

echo Carbon::now()->toDateTimeLocalString();
echo "\n";
echo Carbon::now()->toDateTimeLocalString('minute'); // You can specify precision among: minute, second, millisecond and microsecond

Prototype changed3.0.0string $unitPrecision = 'second'
Prototype changed2.26.0$unitPrecision = 'second'
Method added1.39.0no arguments

Carbon::toDayDateTimeString

no arguments
returns string

Format the instance with day, date and time

Examples:

echo Carbon::now()->toDayDateTimeString();

Method added1.0.0no arguments

Carbon::toAtomString

no arguments
returns string

Format the instance as ATOM

Examples:

echo Carbon::now()->toAtomString();

Method added1.13.0no arguments

Carbon::toCookieString

no arguments
returns string

Format the instance as COOKIE

Examples:

echo Carbon::now()->toCookieString();

Method added1.13.0no arguments

Carbon::toIso8601String

no arguments
returns string

Format the instance as ISO8601

Examples:

echo Carbon::now()->toIso8601String();

Method added1.13.0no arguments

Carbon::toRfc822String

no arguments
returns string

Format the instance as RFC822

Examples:

echo Carbon::now()->toRfc822String();

Method added1.13.0no arguments

Carbon::toIso8601ZuluString

string $unitPrecision = 'second'
returns string

Convert the instance to UTC and return as Zulu ISO8601

Examples:

echo Carbon::now()->toIso8601ZuluString();

Prototype changed3.0.0string $unitPrecision = 'second'
Prototype changed2.26.0$unitPrecision = 'second'
Method added1.24.0no arguments

Carbon::toRfc850String

no arguments
returns string

Format the instance as RFC850

Examples:

echo Carbon::now()->toRfc850String();

Method added1.13.0no arguments

Carbon::toRfc1036String

no arguments
returns string

Format the instance as RFC1036

Examples:

echo Carbon::now()->toRfc1036String();

Method added1.13.0no arguments

Carbon::toRfc1123String

no arguments
returns string

Format the instance as RFC1123

Examples:

echo Carbon::now()->toRfc1123String();

Method added1.13.0no arguments

Carbon::toRfc2822String

no arguments
returns string

Format the instance as RFC2822

Examples:

echo Carbon::now()->toRfc2822String();

Method added1.13.0no arguments

Carbon::toRfc3339String

bool $extended = false
returns string

Format the instance as RFC3339.

Examples:

echo Carbon::now()->toRfc3339String() . "\n";
echo Carbon::now()->toRfc3339String(true) . "\n";

Prototype changed3.0.0bool $extended = false
Prototype changed2.39.0$extended = false
Method added1.13.0no arguments

Carbon::toRssString

no arguments
returns string

Format the instance as RSS

Examples:

echo Carbon::now()->toRssString();

Method added1.13.0no arguments

Carbon::toW3cString

no arguments
returns string

Format the instance as W3C

Examples:

echo Carbon::now()->toW3cString();

Method added1.13.0no arguments

Carbon::toRfc7231String

no arguments
returns string

Format the instance as RFC7231

Examples:

echo Carbon::now()->toRfc7231String();

Method added1.24.0no arguments

Carbon::toArray

no arguments
returns array

Get default array representation.

Examples:

\Carbon\Doc\Generate\var_dump(Carbon::now()->toArray());

Method added1.24.0no arguments

Carbon::toObject

no arguments
returns object

Get default object representation.

Examples:

\Carbon\Doc\Generate\var_dump(Carbon::now()->toObject());

Method added1.39.0no arguments

Carbon::toString

no arguments
returns string

Returns english human-readable complete date string.

Examples:

echo Carbon::now()->toString();

Method added1.39.0no arguments

Carbon::toISOString

bool $keepOffset = false
returns string

Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z, if $keepOffset truthy, offset will be kept: 1977-04-22T01:00:00-05:00).

Examples:

echo Carbon::now('America/Toronto')->toISOString() . "\n";
echo Carbon::now('America/Toronto')->toISOString(true) . "\n";

Prototype changed3.0.0bool $keepOffset = false
Method added1.39.0$keepOffset = false

Carbon::toJSON

no arguments
returns string

Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z) with UTC timezone.

Examples:

echo Carbon::now('America/Toronto')->toJSON();

Method added1.39.0no arguments

Carbon::toDateTime

no arguments
returns DateTime

Return native DateTime PHP object matching the current instance.

Examples:

\Carbon\Doc\Generate\var_dump(Carbon::now()->toDateTime());

Method added1.39.0no arguments

Carbon::toDateTimeImmutable

no arguments
returns DateTimeImmutable

Return native toDateTimeImmutable PHP object matching the current instance.

Examples:

\Carbon\Doc\Generate\var_dump(Carbon::now()->toDateTimeImmutable());

Method added2.23.0no arguments

Carbon::toDate

no arguments
returns DateTime

@alias toDateTime

Return native DateTime PHP object matching the current instance.

Examples:

\Carbon\Doc\Generate\var_dump(Carbon::now()->toDate());

Method added1.39.0no arguments

Carbon::toPeriod

$end = null, $interval = null, $unit = null
returns CarbonPeriod

Create a iterable CarbonPeriod object from current date to a given end date (and optional interval).

Method added2.20.0$end = null, $interval = null, $unit = null

Carbon::range

$end = null, $interval = null, $unit = null
returns CarbonPeriod

Create a iterable CarbonPeriod object from current date to a given end date (and optional interval).

Method added2.20.0$end = null, $interval = null, $unit = null

Carbon::resetToStringFormat

no arguments

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

Method added1.5.0no arguments

Carbon::setToStringFormat

Closure|string|null $format

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.

Prototype changed3.0.0Closure|string|null $format
Method added1.5.0$format

Carbon::__clone

no arguments

Update constructedObjectId on cloned.

Method added2.29.0no arguments

Carbon::instance

DateTimeInterface $date
returns Carbon

Create a Carbon instance from a DateTime one.

Prototype changed3.0.0DateTimeInterface $date
Prototype changed1.26.0$date
Method added1.0.0DateTime $date

Carbon::rawParse

DateTimeInterface|Carbon\WeekDay|Carbon\Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = null
returns Carbon

Create a carbon instance from a string.

This is an alias for the constructor that allows better fluent syntax as it allows you to do Carbon::parse('Monday next week')->fn() rather than (new Carbon('Monday next week'))->fn().

Prototype changed3.0.0DateTimeInterface|Carbon\WeekDay|Carbon\Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = null
Method added2.16.0$time = null, $tz = null

Carbon::parse

DateTimeInterface|Carbon\WeekDay|Carbon\Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = null
returns Carbon

Create a carbon instance from a string.

This is an alias for the constructor that allows better fluent syntax as it allows you to do Carbon::parse('Monday next week')->fn() rather than (new Carbon('Monday next week'))->fn().

Prototype changed3.0.0DateTimeInterface|Carbon\WeekDay|Carbon\Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = null
Method added1.3.0$time = null, $tz = null

Carbon::parseFromLocale

string $time, ?string $locale = null, DateTimeZone|string|int|null $timezone = null
returns Carbon

Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).

Prototype changed3.0.0string $time, ?string $locale = null, DateTimeZone|string|int|null $timezone = null
Prototype changed2.35.0$time, $locale = null, $tz = null
Method added2.16.0$time, $locale, $tz = null

Carbon::now

DateTimeZone|string|int|null $timezone = null
returns Carbon

Get a Carbon instance for the current date and time.

Prototype changed3.0.0DateTimeZone|string|int|null $timezone = null
Method added1.0.0$tz = null

Carbon::today

DateTimeZone|string|int|null $timezone = null
returns Carbon

Create a Carbon instance for today.

Prototype changed3.0.0DateTimeZone|string|int|null $timezone = null
Method added1.1.0$tz = null

Carbon::tomorrow

DateTimeZone|string|int|null $timezone = null
returns Carbon

Create a Carbon instance for tomorrow.

Prototype changed3.0.0DateTimeZone|string|int|null $timezone = null
Method added1.1.0$tz = null

Carbon::yesterday

DateTimeZone|string|int|null $timezone = null
returns Carbon

Create a Carbon instance for yesterday.

Prototype changed3.0.0DateTimeZone|string|int|null $timezone = null
Method added1.1.0$tz = null

Carbon::create

$year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $timezone = null
returns Carbon

Create a new Carbon instance from a specific date and time.

If any of $year, $month or $day are set to null their now() values will be used.

If $hour is null it will be set to its now() value and the default values for $minute and $second will be their now() values.

If $hour is not null then the default values for $minute and $second will be 0.

Prototype changed3.0.0$year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $timezone = null
Prototype changed2.0.0$year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null
Method added1.0.0$year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null

Carbon::createSafe

$year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null
returns Carbon

Create a new safe Carbon instance from a specific date and time.

If any of $year, $month or $day are set to null their now() values will be used.

If $hour is null it will be set to its now() value and the default values for $minute and $second will be their now() values.

If $hour is not null then the default values for $minute and $second will be 0.

If one of the set values is not valid, an InvalidDateException will be thrown.

Prototype changed3.0.0$year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null
Method added1.22.0$year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null

Carbon::createStrict

?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $timezone = null
returns Carbon

Create a new Carbon instance from a specific date and time using strict validation.

Prototype changed3.0.0?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $timezone = null
Method added2.49.0?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null

Carbon::createFromDate

$year = null, $month = null, $day = null, $timezone = null
returns Carbon

Create a Carbon instance from just a date. The time portion is set to now.

Prototype changed3.0.0$year = null, $month = null, $day = null, $timezone = null
Method added1.0.0$year = null, $month = null, $day = null, $tz = null

Carbon::createMidnightDate

$year = null, $month = null, $day = null, $timezone = null
returns Carbon

Create a Carbon instance from just a date. The time portion is set to midnight.

Prototype changed3.0.0$year = null, $month = null, $day = null, $timezone = null
Method added1.24.0$year = null, $month = null, $day = null, $tz = null

Carbon::createFromTime

$hour = 0, $minute = 0, $second = 0, $timezone = null
returns Carbon

Create a Carbon instance from just a time. The date portion is set to today.

Prototype changed3.0.0$hour = 0, $minute = 0, $second = 0, $timezone = null
Prototype changed2.0.0$hour = 0, $minute = 0, $second = 0, $tz = null
Method added1.0.0$hour = null, $minute = null, $second = null, $tz = null

Carbon::createFromTimeString

string $time, DateTimeZone|string|int|null $timezone = null
returns Carbon

Create a Carbon instance from a time string. The date portion is set to today.

Prototype changed3.0.0string $time, DateTimeZone|string|int|null $timezone = null
Method added1.25.0$time, $tz = null

Carbon::rawCreateFromFormat

string $format, string $time, $timezone = null
returns Carbon

Create a Carbon instance from a specific format.

Prototype changed3.0.0string $format, string $time, $timezone = null
Method added2.16.0$format, $time, $tz = null

Carbon::createFromIsoFormat

string $format, string $time, $timezone = null, ?string $locale = 'en', ?Symfony\Contracts\Translation\TranslatorInterface $translator = null
returns Carbon

Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).

Prototype changed3.0.0string $format, string $time, $timezone = null, ?string $locale = 'en', ?Symfony\Contracts\Translation\TranslatorInterface $translator = null
Method added2.16.0$format, $time, $tz = null, $locale = 'en', $translator = null

Carbon::createFromLocaleFormat

string $format, string $locale, string $time, $timezone = null
returns Carbon

Create a Carbon instance from a specific format and a string in a given language.

Prototype changed3.0.0string $format, string $locale, string $time, $timezone = null
Method added2.16.0$format, $locale, $time, $tz = null

Carbon::createFromLocaleIsoFormat

string $format, string $locale, string $time, $timezone = null
returns Carbon

Create a Carbon instance from a specific ISO format and a string in a given language.

Prototype changed3.0.0string $format, string $locale, string $time, $timezone = null
Method added2.16.0$format, $locale, $time, $tz = null

Carbon::make

$var
returns Carbon

Make a Carbon instance from given variable if possible.

Always return a new instance. Parse only strings and only these likely to be dates (skip intervals and recurrences). Throw an exception for invalid format, but otherwise return null.

Method added1.28.0$var

Carbon::getClock

no arguments
returns WrapperClock

Method added3.0.0no arguments

Carbon::diffAsDateInterval

$date = null, bool $absolute = false
returns DateInterval

Get the difference as a DateInterval instance. Return relative interval (negative if $absolute flag is not set to true and the given date is before current one).

Method added3.0.0$date = null, bool $absolute = false

Carbon::diffAsCarbonInterval

$date = null, bool $absolute = false, array $skip = []
returns CarbonInterval

Get the difference as a CarbonInterval instance. Return relative interval (negative if $absolute flag is not set to true and the given date is before current one).

Prototype changed3.0.0$date = null, bool $absolute = false, array $skip = []
Prototype changed2.64.0$date = null, $absolute = true, array $skip = []
Prototype changed2.0.0$date = null, $absolute = true
Prototype changed1.35.0$date = null, $absolute = true, $trimMicroseconds = true
Method added1.26.0$date = null, $absolute = true

Carbon::diffInUnit

Carbon\Unit|string $unit, $date = null, bool $absolute = false, bool $utc = false
returns float

@param Unit|string $unit microsecond, millisecond, second, minute, hour, day, week, month, quarter, year, century, millennium

Prototype changed3.2.0Carbon\Unit|string $unit, $date = null, bool $absolute = false, bool $utc = false
Prototype changed3.1.0Carbon\Unit|string $unit, $date = null, bool $absolute = false
Method added3.0.0string $unit, $date = null, bool $absolute = false

Carbon::diffInYears

$date = null, bool $absolute = false, bool $utc = false
returns float

Get the difference in years

Prototype changed3.2.0$date = null, bool $absolute = false, bool $utc = false
Prototype changed3.0.0$date = null, bool $absolute = false
Prototype changed1.24.0$date = null, $absolute = true
Prototype changed1.23.0self $date = null, $absolute = true
Method added1.0.0Carbon\Carbon $date = null, $absolute = true

Carbon::diffInQuarters

$date = null, bool $absolute = false, bool $utc = false
returns float

Get the difference in quarters.

Prototype changed3.2.0$date = null, bool $absolute = false, bool $utc = false
Prototype changed3.0.0$date = null, bool $absolute = false
Method added2.31.0$date = null, $absolute = true

Carbon::diffInMonths

$date = null, bool $absolute = false, bool $utc = false
returns float

Get the difference in months.

Prototype changed3.2.0$date = null, bool $absolute = false, bool $utc = false
Prototype changed3.0.0$date = null, bool $absolute = false
Prototype changed1.24.0$date = null, $absolute = true
Prototype changed1.23.0self $date = null, $absolute = true
Method added1.0.0Carbon\Carbon $date = null, $absolute = true

Carbon::diffInWeeks

$date = null, bool $absolute = false, bool $utc = false
returns float

Get the difference in weeks.

Prototype changed3.2.0$date = null, bool $absolute = false, bool $utc = false
Prototype changed3.0.0$date = null, bool $absolute = false
Prototype changed1.24.0$date = null, $absolute = true
Prototype changed1.23.0self $date = null, $absolute = true
Method added1.11.0Carbon\Carbon $date = null, $absolute = true

Carbon::diffInDays

$date = null, bool $absolute = false, bool $utc = false
returns float

Get the difference in days.

Prototype changed3.2.0$date = null, bool $absolute = false, bool $utc = false
Prototype changed3.0.0$date = null, bool $absolute = false
Prototype changed1.24.0$date = null, $absolute = true
Prototype changed1.23.0self $date = null, $absolute = true
Method added1.0.0Carbon\Carbon $date = null, $absolute = true

Carbon::diffInDaysFiltered

Closure $callback, $date = null, bool $absolute = false
returns int

Get the difference in days using a filter closure.

Prototype changed3.0.0Closure $callback, $date = null, bool $absolute = false
Prototype changed1.24.0Closure $callback, $date = null, $absolute = true
Prototype changed1.23.0Closure $callback, self $date = null, $absolute = true
Method added1.12.0Closure $callback, Carbon\Carbon $date = null, $absolute = true

Carbon::diffInHoursFiltered

Closure $callback, $date = null, bool $absolute = false
returns int

Get the difference in hours using a filter closure.

Prototype changed3.0.0Closure $callback, $date = null, bool $absolute = false
Prototype changed1.24.0Closure $callback, $date = null, $absolute = true
Prototype changed1.23.0Closure $callback, self $date = null, $absolute = true
Method added1.18.0Closure $callback, Carbon\Carbon $date = null, $absolute = true

Carbon::diffFiltered

Carbon\CarbonInterval $ci, Closure $callback, $date = null, bool $absolute = false
returns int

Get the difference by the given interval using a filter closure.

Prototype changed3.0.0Carbon\CarbonInterval $ci, Closure $callback, $date = null, bool $absolute = false
Prototype changed1.24.0Carbon\CarbonInterval $ci, Closure $callback, $date = null, $absolute = true
Prototype changed1.23.0Carbon\CarbonInterval $ci, Closure $callback, self $date = null, $absolute = true
Method added1.18.0Carbon\CarbonInterval $ci, Closure $callback, Carbon\Carbon $date = null, $absolute = true

Carbon::diffInWeekdays

$date = null, bool $absolute = false
returns int

Get the difference in weekdays.

Prototype changed3.0.0$date = null, bool $absolute = false
Prototype changed1.24.0$date = null, $absolute = true
Prototype changed1.23.0self $date = null, $absolute = true
Method added1.12.0Carbon\Carbon $date = null, $absolute = true

Carbon::diffInWeekendDays

$date = null, bool $absolute = false
returns int

Get the difference in weekend days using a filter.

Prototype changed3.0.0$date = null, bool $absolute = false
Prototype changed1.24.0$date = null, $absolute = true
Prototype changed1.23.0self $date = null, $absolute = true
Method added1.12.0Carbon\Carbon $date = null, $absolute = true

Carbon::diffInHours

$date = null, bool $absolute = false
returns float

Get the difference in hours.

Prototype changed3.0.0$date = null, bool $absolute = false
Prototype changed1.24.0$date = null, $absolute = true
Prototype changed1.23.0self $date = null, $absolute = true
Method added1.0.0Carbon\Carbon $date = null, $absolute = true

Carbon::diffInMinutes

$date = null, bool $absolute = false
returns float

Get the difference in minutes.

Prototype changed3.0.0$date = null, bool $absolute = false
Prototype changed1.24.0$date = null, $absolute = true
Prototype changed1.23.0self $date = null, $absolute = true
Method added1.0.0Carbon\Carbon $date = null, $absolute = true

Carbon::diffInSeconds

$date = null, bool $absolute = false
returns float

Get the difference in seconds.

Prototype changed3.0.0$date = null, bool $absolute = false
Prototype changed1.24.0$date = null, $absolute = true
Prototype changed1.23.0self $date = null, $absolute = true
Method added1.0.0Carbon\Carbon $date = null, $absolute = true

Carbon::diffInMicroseconds

$date = null, bool $absolute = false
returns float

Get the difference in microseconds.

Prototype changed3.0.0$date = null, bool $absolute = false
Method added1.39.0$date = null, $absolute = true

Carbon::diffInMilliseconds

$date = null, bool $absolute = false
returns float

Get the difference in milliseconds.

Prototype changed3.0.0$date = null, bool $absolute = false
Method added1.39.0$date = null, $absolute = true

Carbon::secondsSinceMidnight

no arguments
returns float

The number of seconds since midnight.

Method added1.14.0no arguments

Carbon::secondsUntilEndOfDay

no arguments
returns float

The number of seconds until 23:59:59.

Method added1.14.0no arguments

Carbon::diffForHumans

$other = null, $syntax = null, $short = false, $parts = 1, $options = null
returns string

Get the difference in a human readable format in the current locale from current instance to an other instance given (or now if null given).

Examples:

echo Carbon::tomorrow()->diffForHumans() . "\n";
echo Carbon::tomorrow()->diffForHumans(['parts' => 2]) . "\n";
echo Carbon::tomorrow()->diffForHumans(['parts' => 3, 'join' => true]) . "\n";
echo Carbon::tomorrow()->diffForHumans(Carbon::yesterday()) . "\n";
echo Carbon::tomorrow()->diffForHumans(Carbon::yesterday(), ['short' => true]) . "\n";

Prototype changed2.0.0$other = null, $syntax = null, $short = false, $parts = 1, $options = null
Prototype changed1.25.0$other = null, $absolute = false, $short = false, $parts = 1
Prototype changed1.23.0self $other = null, $absolute = false, $short = false, $parts = 1
Prototype changed1.22.0Carbon\Carbon $other = null, $absolute = false, $short = false
Prototype changed1.14.0Carbon\Carbon $other = null, $absolute = false
Method added1.0.0Carbon\Carbon $other = null

Carbon::from

$other = null, $syntax = null, $short = false, $parts = 1, $options = null
returns string

@alias diffForHumans

Get the difference in a human readable format in the current locale from current instance to an other instance given (or now if null given).

Prototype changed2.0.0$other = null, $syntax = null, $short = false, $parts = 1, $options = null
Method added1.39.0$other = null, $absolute = false, $short = false, $parts = 1

Carbon::since

$other = null, $syntax = null, $short = false, $parts = 1, $options = null

@alias diffForHumans

Get the difference in a human readable format in the current locale from current instance to an other instance given (or now if null given).

Prototype changed2.0.0$other = null, $syntax = null, $short = false, $parts = 1, $options = null
Method added1.39.0$other = null, $absolute = false, $short = false, $parts = 1

Carbon::to

$other = null, $syntax = null, $short = false, $parts = 1, $options = null
returns string

Get the difference in a human readable format in the current locale from an other instance given (or now if null given) to current instance.

When comparing a value in the past to default now: 1 hour from now 5 months from now

When comparing a value in the future to default now: 1 hour ago 5 months ago

When comparing a value in the past to another value: 1 hour after 5 months after

When comparing a value in the future to another value: 1 hour before 5 months before

Prototype changed2.0.0$other = null, $syntax = null, $short = false, $parts = 1, $options = null
Method added1.39.0$other = null, $absolute = false, $short = false, $parts = 1

Carbon::until

$other = null, $syntax = null, $short = false, $parts = 1, $options = null
returns string

@alias to

Get the difference in a human readable format in the current locale from an other instance given (or now if null given) to current instance.

Prototype changed2.0.0$other = null, $syntax = null, $short = false, $parts = 1, $options = null
Method added1.39.0$other = null, $absolute = false, $short = false, $parts = 1

Carbon::fromNow

$syntax = null, $short = false, $parts = 1, $options = null
returns string

Get the difference in a human readable format in the current locale from current instance to now.

Prototype changed2.0.0$syntax = null, $short = false, $parts = 1, $options = null
Method added1.39.0$absolute = null, $short = false, $parts = 1

Carbon::toNow

$syntax = null, $short = false, $parts = 1, $options = null
returns string

Get the difference in a human readable format in the current locale from an other instance given to now

Prototype changed2.0.0$syntax = null, $short = false, $parts = 1, $options = null
Method added1.39.0$absolute = null, $short = false, $parts = 1

Carbon::ago

$syntax = null, $short = false, $parts = 1, $options = null
returns string

Get the difference in a human readable format in the current locale from an other instance given to now

Prototype changed2.16.0$syntax = null, $short = false, $parts = 1, $options = null
Method added1.39.0$absolute = null, $short = false, $parts = 1

Carbon::timespan

$other = null, $timezone = null
returns string

Get the difference in a human-readable format in the current locale from current instance to another instance given (or now if null given).

Method added2.16.0$other = null, $timezone = null

Carbon::calendar

$referenceTime = null, array $formats = []
returns string

Returns either day of week + time (e.g. "Last Friday at 3:30 PM") if reference time is within 7 days, or a calendar date (e.g. "10/29/2017") otherwise.

Language, date and time formats will change according to the current locale.

Method added2.0.0$referenceTime = null, array $formats = []

Carbon::macro

string $name, ?callable $macro

Register a custom macro.

Pass null macro to remove it.

Examples:

$userSettings = [
  'locale' => 'pt',
  'timezone' => 'America/Sao_Paulo',
];
Carbon::macro('userFormat', function () use ($userSettings) {
  return $this->copy()->locale($userSettings['locale'])->tz($userSettings['timezone'])->calendar();
});
echo Carbon::yesterday()->hours(11)->userFormat();

Prototype changed3.0.1string $name, ?callable $macro
Prototype changed3.0.0string $name, callable|object $macro
Method added1.26.0$name, $macro

Carbon::resetMacros

no arguments

Remove all macros and generic macros.

Method added1.39.0no arguments

Carbon::genericMacro

callable $macro, int $priority = 0

Register a custom macro.

Prototype changed3.0.1callable $macro, int $priority = 0
Prototype changed3.0.0callable|object $macro, int $priority = 0
Method added2.1.0$macro, $priority = 0

Carbon::hasMacro

string $name
returns bool

Checks if macro is registered globally.

Prototype changed3.0.0string $name
Method added1.26.0$name

Carbon::getMacro

string $name
returns callable

Get the raw callable macro registered globally for a given name.

Prototype changed3.0.0string $name
Method added2.29.0$name

Carbon::hasLocalMacro

string $name
returns bool

Checks if macro is registered globally or locally.

Prototype changed3.0.0string $name
Method added2.29.0$name

Carbon::getLocalMacro

string $name
returns callable

Get the raw callable macro registered globally or locally for a given name.

Prototype changed3.0.0string $name
Method added2.29.0$name

Carbon::mixin

object|string $mixin

Mix another object into the class.

Examples:

Carbon::mixin(new class {
  public function addMoon() {
    return function () {
      return $this->addDays(30);
    };
  }
  public function subMoon() {
    return function () {
      return $this->subDays(30);
    };
  }
});
$fullMoon = Carbon::create('2018-12-22');
$nextFullMoon = $fullMoon->addMoon();
$blackMoon = Carbon::create('2019-01-06');
$previousBlackMoon = $blackMoon->subMoon();
echo "$nextFullMoon\n";
echo "$previousBlackMoon\n";

Prototype changed3.0.0object|string $mixin
Method added1.26.0$mixin

Carbon::getMidDayAt

no arguments
returns int

get midday/noon hour

Method added1.24.0no arguments

Carbon::setMidDayAt

$hour

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather consider mid-day is always 12pm, then if you need to test if it's an other hour, test it explicitly: $date->format('G') == 13 or to set explicitly to a given hour: $date->setTime(13, 0, 0, 0)

Set midday/noon hour

Method added1.24.0$hour

Carbon::midDay

no arguments
returns Carbon

Modify to midday, default to self::$midDayAt

Method added1.24.0no arguments

Carbon::next

$modifier = null
returns Carbon

Modify to the next occurrence of a given modifier such as a day of the week. If no modifier is provided, modify to the next occurrence of the current day of the week. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

Prototype changed2.20.0$modifier = null
Method added1.3.0$dayOfWeek = null

Carbon::nextWeekday

no arguments
returns Carbon

Go forward to the next weekday.

Method added1.22.0no arguments

Carbon::previousWeekday

no arguments
returns Carbon

Go backward to the previous weekday.

Method added1.22.0no arguments

Carbon::nextWeekendDay

no arguments
returns Carbon

Go forward to the next weekend day.

Method added1.22.0no arguments

Carbon::previousWeekendDay

no arguments
returns Carbon

Go backward to the previous weekend day.

Method added1.22.0no arguments

Carbon::previous

$modifier = null
returns Carbon

Modify to the previous occurrence of a given modifier such as a day of the week. If no dayOfWeek is provided, modify to the previous occurrence of the current day of the week. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

Prototype changed2.20.0$modifier = null
Method added1.3.0$dayOfWeek = null

Carbon::firstOfMonth

$dayOfWeek = null
returns Carbon

Modify to the first occurrence of a given day of the week in the current month. If no dayOfWeek is provided, modify to the first day of the current month. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

Method added1.3.0$dayOfWeek = null

Carbon::lastOfMonth

$dayOfWeek = null
returns Carbon

Modify to the last occurrence of a given day of the week in the current month. If no dayOfWeek is provided, modify to the last day of the current month. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

Method added1.3.0$dayOfWeek = null

Carbon::nthOfMonth

$nth, $dayOfWeek
returns mixed

Modify to the given occurrence of a given day of the week in the current month. If the calculated occurrence is outside the scope of the current month, then return false and no modifications are made. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

Method added1.3.0$nth, $dayOfWeek

Carbon::firstOfQuarter

$dayOfWeek = null
returns Carbon

Modify to the first occurrence of a given day of the week in the current quarter. If no dayOfWeek is provided, modify to the first day of the current quarter. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

Method added1.3.0$dayOfWeek = null

Carbon::lastOfQuarter

$dayOfWeek = null
returns Carbon

Modify to the last occurrence of a given day of the week in the current quarter. If no dayOfWeek is provided, modify to the last day of the current quarter. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

Method added1.3.0$dayOfWeek = null

Carbon::nthOfQuarter

$nth, $dayOfWeek
returns mixed

Modify to the given occurrence of a given day of the week in the current quarter. If the calculated occurrence is outside the scope of the current quarter, then return false and no modifications are made. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

Method added1.3.0$nth, $dayOfWeek

Carbon::firstOfYear

$dayOfWeek = null
returns Carbon

Modify to the first occurrence of a given day of the week in the current year. If no dayOfWeek is provided, modify to the first day of the current year. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

Method added1.3.0$dayOfWeek = null

Carbon::lastOfYear

$dayOfWeek = null
returns Carbon

Modify to the last occurrence of a given day of the week in the current year. If no dayOfWeek is provided, modify to the last day of the current year. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

Method added1.3.0$dayOfWeek = null

Carbon::nthOfYear

$nth, $dayOfWeek
returns mixed

Modify to the given occurrence of a given day of the week in the current year. If the calculated occurrence is outside the scope of the current year, then return false and no modifications are made. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

Method added1.3.0$nth, $dayOfWeek

Carbon::average

$date = null
returns Carbon

Modify the current instance to the average of a given instance (default now) and the current instance (second-precision).

Prototype changed1.24.0$date = null
Prototype changed1.23.0self $date = null
Method added1.7.0Carbon\Carbon $date = null

Carbon::closest

$date1, $date2
returns Carbon

Get the closest date from the instance (second-precision).

Prototype changed1.24.0$date1, $date2
Prototype changed1.23.0self $dt1, self $dt2
Method added1.21.0Carbon\Carbon $dt1, Carbon\Carbon $dt2

Carbon::farthest

$date1, $date2
returns Carbon

Get the farthest date from the instance (second-precision).

Prototype changed1.24.0$date1, $date2
Prototype changed1.23.0self $dt1, self $dt2
Method added1.21.0Carbon\Carbon $dt1, Carbon\Carbon $dt2

Carbon::min

$date = null
returns Carbon

Get the minimum instance between a given instance (default now) and the current instance.

Prototype changed1.24.0$date = null
Prototype changed1.23.0self $date = null
Method added1.8.0Carbon\Carbon $date = null

Carbon::minimum

$date = null
returns Carbon

Get the minimum instance between a given instance (default now) and the current instance.

Prototype changed1.24.0$date = null
Prototype changed1.23.0self $date = null
Method added1.22.0Carbon\Carbon $date = null

Carbon::max

$date = null
returns Carbon

Get the maximum instance between a given instance (default now) and the current instance.

Prototype changed1.24.0$date = null
Prototype changed1.23.0self $date = null
Method added1.8.0Carbon\Carbon $date = null

Carbon::maximum

$date = null
returns Carbon

Get the maximum instance between a given instance (default now) and the current instance.

Prototype changed1.24.0$date = null
Prototype changed1.23.0self $date = null
Method added1.22.0Carbon\Carbon $date = null

Carbon::change

$modifier
returns Carbon

Similar to native modify() method of DateTime but can handle more grammars.

Examples:

echo Carbon::now()->change('next 2pm');

Method added2.20.0$modifier

Carbon::isImmutable

no arguments
returns bool

Returns true if the current class/instance is immutable.

Method added2.0.0no arguments

Carbon::toMutable

no arguments
returns Carbon

Return a mutable copy of the instance.

Method added2.0.0no arguments

Carbon::toImmutable

no arguments
returns CarbonImmutable

Return a immutable copy of the instance.

Method added2.0.0no arguments

Carbon::cast

string $className
returns mixed

Cast the current instance into the given class.

Prototype changed2.8.0string $className
Method added1.39.0$className

Carbon::settings

array $settings
returns Carbon

Set specific options. - 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

Method added2.0.0array $settings

Carbon::getSettings

no arguments
returns array

Returns current local settings.

Method added2.3.0no arguments

Carbon::__debugInfo

no arguments
returns array

Show truthy properties on \Carbon\Doc\Generate\var_dump().

Method added1.39.0no arguments

Carbon::useStrictMode

bool $strictModeEnabled = true

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method.

Prototype changed3.0.0bool $strictModeEnabled = true
Method added2.0.0$strictModeEnabled = true

Carbon::isStrictModeEnabled

no arguments
returns bool

Returns true if the strict mode is globally in use, false else. (It can be overridden in specific instances.)

Method added2.0.0no arguments

Carbon::useMonthsOverflow

bool $monthsOverflow = true

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method. Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).

Prototype changed3.0.0bool $monthsOverflow = true
Method added1.22.0$monthsOverflow = true

Carbon::resetMonthsOverflow

no arguments

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method. Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).

Method added1.22.0no arguments

Carbon::shouldOverflowMonths

no arguments
returns bool

Get the month overflow global behavior (can be overridden in specific instances).

Method added1.22.0no arguments

Carbon::useYearsOverflow

bool $yearsOverflow = true

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method. Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).

Prototype changed3.0.0bool $yearsOverflow = true
Method added1.24.0$yearsOverflow = true

Carbon::resetYearsOverflow

no arguments

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method. Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).

Method added1.24.0no arguments

Carbon::shouldOverflowYears

no arguments
returns bool

Get the month overflow global behavior (can be overridden in specific instances).

Method added1.24.0no arguments

Carbon::hasLocalTranslator

no arguments
returns bool

Return true if the current instance has its own translator.

Method added2.29.0no arguments

Carbon::getLocalTranslator

no arguments
returns Symfony\Contracts\Translation\TranslatorInterface

Get the translator of the current instance or the default if none set.

Method added2.0.0no arguments

Carbon::setLocalTranslator

Symfony\Contracts\Translation\TranslatorInterface $translator
returns Carbon

Set the translator for the current instance.

Prototype changed3.0.0Symfony\Contracts\Translation\TranslatorInterface $translator
Method added2.0.0Symfony\Component\Translation\TranslatorInterface $translator

Carbon::getTranslationMessageWith

$translator, string $key, ?string $locale = null, ?string $default = null
returns string|Closure|null

Returns raw translation message for a given key.

Method added2.8.0$translator, string $key, ?string $locale = null, ?string $default = null

Carbon::getTranslationMessage

string $key, ?string $locale = null, ?string $default = null, $translator = null
returns string

Returns raw translation message for a given key.

Prototype changed2.8.0string $key, ?string $locale = null, ?string $default = null, $translator = null
Method added2.0.0string $key, ?string $locale = null, ?string $default = null

Carbon::translateWith

Symfony\Contracts\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null
returns string

Translate using translation string or callback available.

Prototype changed3.0.0Symfony\Contracts\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null
Method added2.8.0Symfony\Component\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null

Carbon::translate

string $key, array $parameters = [], string|int|float|null $number = null, ?Symfony\Contracts\Translation\TranslatorInterface $translator = null, bool $altNumbers = false
returns string

Translate using translation string or callback available.

Prototype changed3.0.0string $key, array $parameters = [], string|int|float|null $number = null, ?Symfony\Contracts\Translation\TranslatorInterface $translator = null, bool $altNumbers = false
Prototype changed2.23.0string $key, array $parameters = [], $number = null, ?Symfony\Component\Translation\TranslatorInterface $translator = null, bool $altNumbers = false
Prototype changed2.8.0string $key, array $parameters = [], $number = null, ?Symfony\Component\Translation\TranslatorInterface $translator = null
Method added2.0.0string $key, array $parameters = [], $number = null

Carbon::translateNumber

int $number
returns string

Returns the alternative number for a given integer if available in the current locale.

Method added2.23.0int $number

Carbon::translateTimeString

string $timeString, ?string $from = null, ?string $to = null, int $mode = 31
returns string

Translate a time string from a locale to an other.

Prototype changed3.0.0string $timeString, ?string $from = null, ?string $to = null, int $mode = 31
Prototype changed2.35.0$timeString, $from = null, $to = null, $mode = 31
Method added2.16.0$timeString, $from = null, $to = null, $mode = 15

Carbon::translateTimeStringTo

string $timeString, ?string $to = null
returns string

Translate a time string from the current locale (`$date->locale()`) to an other.

Prototype changed3.0.0string $timeString, ?string $to = null
Method added2.16.0$timeString, $to = null

Carbon::locale

?string $locale = null, string $fallbackLocales
returns Carbon|string

Get/set the locale for the current instance.

Prototype changed3.0.0?string $locale = null, string $fallbackLocales
Prototype changed2.16.0?string $locale = null, $fallbackLocales
Method added2.0.0?string $locale = null

Carbon::getLocale

no arguments
returns string

Get the current translator locale.

Method added1.18.0no arguments

Carbon::setLocale

string $locale

Set the current translator locale and indicate if the source locale file exists. Pass 'auto' as locale to use the closest language to the current LC_TIME locale.

Prototype changed3.0.0string $locale
Method added1.18.0$locale

Carbon::setFallbackLocale

string $locale

Set the fallback locale.

Prototype changed3.0.0string $locale
Method added2.16.0$locale

Carbon::getFallbackLocale

no arguments
returns string

Get the fallback locale.

Method added2.16.0no arguments

Carbon::executeWithLocale

string $locale, callable $func
returns mixed

Set the current locale to the given, execute the passed function, reset the locale to previous one, then return the result of the closure (or null if the closure was void).

Prototype changed3.0.0string $locale, callable $func
Method added1.31.0$locale, $func

Carbon::localeHasShortUnits

string $locale
returns bool

Returns true if the given locale is internally supported and has short-units support. Support is considered enabled if either year, day or hour has a short variant translated.

Prototype changed3.0.0string $locale
Method added1.31.0$locale

Carbon::localeHasDiffSyntax

string $locale
returns bool

Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after). Support is considered enabled if the 4 sentences are translated in the given locale.

Prototype changed3.0.0string $locale
Method added1.31.0$locale

Carbon::localeHasDiffOneDayWords

string $locale
returns bool

Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow). Support is considered enabled if the 3 words are translated in the given locale.

Prototype changed3.0.0string $locale
Method added1.31.0$locale

Carbon::localeHasDiffTwoDayWords

string $locale
returns bool

Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow). Support is considered enabled if the 2 words are translated in the given locale.

Prototype changed3.0.0string $locale
Method added1.31.0$locale

Carbon::localeHasPeriodSyntax

$locale
returns bool

Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X). Support is considered enabled if the 4 sentences are translated in the given locale.

Method added1.31.0$locale

Carbon::getAvailableLocales

no arguments
returns array

Returns the list of internally available locales and already loaded custom locales. (It will ignore custom translator dynamic loading.)

Method added1.31.0no arguments

Carbon::getAvailableLocalesInfo

no arguments
returns Language[]

Returns list of Language object for each available locale. This object allow you to get the ISO name, native name, region and variant of the locale.

Method added2.10.1no arguments

Carbon::setHumanDiffOptions

int $humanDiffOptions

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method.

Prototype changed3.0.0int $humanDiffOptions
Method added1.26.0$humanDiffOptions

Carbon::enableHumanDiffOption

int $humanDiffOption

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method.

Prototype changed3.0.0int $humanDiffOption
Method added1.26.0$humanDiffOption

Carbon::disableHumanDiffOption

int $humanDiffOption

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method.

Prototype changed3.0.0int $humanDiffOption
Method added1.26.0$humanDiffOption

Carbon::getHumanDiffOptions

no arguments
returns int

Return default humanDiff() options (merged flags as integer).

Method added1.26.0no arguments

Carbon::setTranslator

Symfony\Contracts\Translation\TranslatorInterface $translator

Set the default translator instance to use.

Prototype changed3.0.0Symfony\Contracts\Translation\TranslatorInterface $translator
Method added1.18.0Symfony\Component\Translation\TranslatorInterface $translator

Carbon::getTranslator

no arguments
returns Symfony\Contracts\Translation\TranslatorInterface

Initialize the default translator instance if necessary.

Method added1.18.0no arguments

Carbon::roundUnit

string $unit, DateInterval|string|int|float $precision = 1, callable|string $function = 'round'
returns Carbon

Round the current instance at the given unit with given precision if specified and the given function.

Prototype changed3.0.0string $unit, DateInterval|string|int|float $precision = 1, callable|string $function = 'round'
Method added2.0.0$unit, $precision = 1, $function = 'round'

Carbon::floorUnit

string $unit, DateInterval|string|int|float $precision = 1
returns Carbon

Truncate the current instance at the given unit with given precision if specified.

Prototype changed3.0.0string $unit, DateInterval|string|int|float $precision = 1
Method added2.0.0$unit, $precision = 1

Carbon::ceilUnit

string $unit, DateInterval|string|int|float $precision = 1
returns Carbon

Ceil the current instance at the given unit with given precision if specified.

Prototype changed3.0.0string $unit, DateInterval|string|int|float $precision = 1
Method added2.0.0$unit, $precision = 1

Carbon::round

DateInterval|string|int|float $precision = 1, callable|string $function = 'round'
returns Carbon

Round the current instance second with given precision if specified.

Prototype changed3.0.0DateInterval|string|int|float $precision = 1, callable|string $function = 'round'
Method added2.0.0$precision = 1, $function = 'round'

Carbon::floor

DateInterval|string|int|float $precision = 1
returns Carbon

Round the current instance second with given precision if specified.

Prototype changed3.0.0DateInterval|string|int|float $precision = 1
Method added2.0.0$precision = 1

Carbon::ceil

DateInterval|string|int|float $precision = 1
returns Carbon

Ceil the current instance second with given precision if specified.

Prototype changed3.0.0DateInterval|string|int|float $precision = 1
Method added2.0.0$precision = 1

Carbon::roundWeek

Carbon\WeekDay|int|null $weekStartsAt = null
returns Carbon

Round the current instance week.

Prototype changed3.0.0Carbon\WeekDay|int|null $weekStartsAt = null
Method added2.0.0$weekStartsAt = null

Carbon::floorWeek

Carbon\WeekDay|int|null $weekStartsAt = null
returns Carbon

Truncate the current instance week.

Prototype changed3.0.0Carbon\WeekDay|int|null $weekStartsAt = null
Method added2.0.0$weekStartsAt = null

Carbon::ceilWeek

Carbon\WeekDay|int|null $weekStartsAt = null
returns Carbon

Ceil the current instance week.

Prototype changed3.0.0Carbon\WeekDay|int|null $weekStartsAt = null
Method added2.0.0$weekStartsAt = null

Carbon::serialize

no arguments
returns string

Return a serialized string of the instance.

Method added1.22.0no arguments

Carbon::fromSerialized

$value
returns Carbon

Create an instance from a serialized string.

Method added1.22.0$value

Carbon::__sleep

no arguments
returns array

Returns the list of properties to dump on serialize() called on.

Only used by PHP < 7.4.

Method added2.0.0no arguments

Carbon::jsonSerialize

no arguments
returns mixed

Prepare the object for JSON serialization.

Method added1.26.0no arguments

Carbon::serializeUsing

callable|string|null $format

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather transform Carbon object before the serialization.

JSON serialize all Carbon instances using the given callback.

Prototype changed3.0.0callable|string|null $format
Method added1.26.0$callback

Carbon::cleanupDumpProperties

no arguments
returns Carbon

Cleanup properties attached to the public scope of DateTime when a dump of the date is requested. foreach ($date as $_) {} serializer($date) var_export($date) get_object_vars($date)

Method added2.29.0no arguments

Carbon::setTestNow

mixed $testNow = null

Set a Carbon instance (real or mock) to be returned when a "now" instance is created. The provided instance will be returned specifically under the following conditions: - A call to the static now() method, ex. Carbon::now() - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null) - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now') - When a string containing the desired time is passed to Carbon::parse().

Note the timezone parameter was left out of the examples above and has no affect as the mock value will be returned regardless of its value.

Only the moment is mocked with setTestNow(), the timezone will still be the one passed as parameter of date_default_timezone_get() as a fallback (see setTestNowAndTimezone()).

To clear the test instance call this method using the default parameter of null.

/!\ Use this method for unit tests only.

Prototype changed3.0.0mixed $testNow = null
Prototype changed1.22.0$testNow = null
Method added1.3.0Carbon\Carbon $testNow = null

Carbon::setTestNowAndTimezone

$testNow = null, $timezone = null

Set a Carbon instance (real or mock) to be returned when a "now" instance is created. The provided instance will be returned specifically under the following conditions: - A call to the static now() method, ex. Carbon::now() - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null) - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now') - When a string containing the desired time is passed to Carbon::parse().

It will also align default timezone (e.g. call date_default_timezone_set()) with the second argument or if null, with the timezone of the given date object.

To clear the test instance call this method using the default parameter of null.

/!\ Use this method for unit tests only.

Prototype changed3.0.0$testNow = null, $timezone = null
Method added2.54.0$testNow = null, $tz = null

Carbon::withTestNow

mixed $testNow, callable $callback
returns mixed

Temporarily sets a static date to be used within the callback. Using setTestNow to set the date, executing the callback, then clearing the test instance.

/!\ Use this method for unit tests only.

Prototype changed3.0.0mixed $testNow, callable $callback
Prototype changed2.67.0$testNow, $callback
Method added2.41.0$testNow = null, $callback = null

Carbon::getTestNow

no arguments
returns Closure|CarbonInterface|null

Get the Carbon instance (real or mock) to be returned when a "now" instance is created.

Method added1.3.0no arguments

Carbon::hasTestNow

no arguments
returns bool

Determine if there is a valid test instance set. A valid test instance is anything that is not null.

Method added1.3.0no arguments

Carbon::createFromTimestamp

string|int|float $timestamp, DateTimeZone|string|int|null $timezone = null
returns Carbon

Create a Carbon instance from a timestamp and set the timezone (UTC by default).

Timestamp input can be given as int, float or a string containing one or more numbers.

Prototype changed3.0.0string|int|float $timestamp, DateTimeZone|string|int|null $timezone = null
Method added1.0.0$timestamp, $tz = null

Carbon::createFromTimestampUTC

string|int|float $timestamp
returns Carbon

Create a Carbon instance from a timestamp keeping the timezone to UTC.

Timestamp input can be given as int, float or a string containing one or more numbers.

Prototype changed3.0.0string|int|float $timestamp
Method added1.0.0$timestamp

Carbon::createFromTimestampMsUTC

$timestamp
returns Carbon

Create a Carbon instance from a timestamp in milliseconds.

Timestamp input can be given as int, float or a string containing one or more numbers.

Method added2.41.0$timestamp

Carbon::createFromTimestampMs

string|int|float $timestamp, DateTimeZone|string|int|null $timezone = null
returns Carbon

Create a Carbon instance from a timestamp in milliseconds.

Timestamp input can be given as int, float or a string containing one or more numbers.

Prototype changed3.0.0string|int|float $timestamp, DateTimeZone|string|int|null $timezone = null
Method added1.23.0$timestamp, $tz = null

Carbon::timestamp

string|int|float $timestamp
returns Carbon

Set the instance's timestamp.

Timestamp input can be given as int, float or a string containing one or more numbers.

Prototype changed3.0.0string|int|float $timestamp
Prototype changed2.41.0$unixTimestamp
Method added1.0.0$value

Carbon::getPreciseTimestamp

$precision = 6
returns float

Returns a timestamp rounded with the given precision (6 by default).

Examples:

getPreciseTimestamp()   1532087464437474 (microsecond maximum precision)

getPreciseTimestamp(6)  1532087464437474

getPreciseTimestamp(5)  153208746443747  (1/100000 second precision)

getPreciseTimestamp(4)  15320874644375   (1/10000 second precision)

getPreciseTimestamp(3)  1532087464437    (millisecond precision)

getPreciseTimestamp(2)  153208746444     (1/100 second precision)

getPreciseTimestamp(1)  15320874644      (1/10 second precision)

getPreciseTimestamp(0)  1532087464       (second precision)

getPreciseTimestamp(-1) 153208746        (10 second precision)

getPreciseTimestamp(-2) 15320875         (100 second precision)

Method added2.0.0$precision = 6

Carbon::valueOf

no arguments
returns float

Returns the milliseconds timestamps used amongst other by Date javascript objects.

Method added2.0.0no arguments

Carbon::getTimestampMs

no arguments
returns int

Returns the timestamp with millisecond precision.

Method added2.51.0no arguments

Carbon::unix

no arguments
returns int

@alias getTimestamp

Returns the UNIX timestamp for the current date.

Method added2.0.0no arguments

Carbon::addRealUnit

string $unit, $value = 1
returns Carbon

Prefer to use add addUTCUnit() which more accurately defines what it's doing.
Add seconds to the instance using timestamp. Positive $value travels forward while negative $value travels into the past.

Prototype changed3.0.0string $unit, $value = 1
Method added2.0.0$unit, $value = 1

Carbon::addUTCUnit

string $unit, $value = 1
returns Carbon

Add seconds to the instance using timestamp. Positive $value travels forward while negative $value travels into the past.

Method added3.2.0string $unit, $value = 1

Carbon::subRealUnit

$unit, $value = 1
returns Carbon

Prefer to use add subUTCUnit() which more accurately defines what it's doing.
Subtract seconds to the instance using timestamp. Positive $value travels into the past while negative $value travels forward.

Method added2.0.0$unit, $value = 1

Carbon::subUTCUnit

$unit, $value = 1
returns Carbon

Subtract seconds to the instance using timestamp. Positive $value travels into the past while negative $value travels forward.

Method added3.2.0$unit, $value = 1

Carbon::isModifiableUnit

$unit
returns bool

Returns true if a property can be changed via setter.

Method added2.0.0$unit

Carbon::rawAdd

DateInterval $interval
returns Carbon

Call native PHP DateTime/DateTimeImmutable add() method.

Method added2.36.0DateInterval $interval

Carbon::addUnit

Carbon\Unit|string $unit, $value = 1, ?bool $overflow = null
returns Carbon

Add given units to the current instance.

Prototype changed3.1.0Carbon\Unit|string $unit, $value = 1, ?bool $overflow = null
Prototype changed3.0.0string $unit, $value = 1, ?bool $overflow = null
Method added2.0.0$unit, $value = 1, $overflow = null

Carbon::subUnit

Carbon\Unit|string $unit, $value = 1, ?bool $overflow = null
returns Carbon

Subtract given units to the current instance.

Prototype changed3.1.0Carbon\Unit|string $unit, $value = 1, ?bool $overflow = null
Prototype changed3.0.0string $unit, $value = 1, ?bool $overflow = null
Method added2.0.0$unit, $value = 1, $overflow = null

Carbon::rawSub

DateInterval $interval
returns Carbon

Call native PHP DateTime/DateTimeImmutable sub() method.

Method added2.36.0DateInterval $interval

Carbon::subtract

$unit, $value = 1, ?bool $overflow = null
returns Carbon

Subtract given units or interval to the current instance.

Prototype changed3.0.0$unit, $value = 1, ?bool $overflow = null
Method added2.0.0$unit, $value = 1, $overflow = null

Carbon::isoWeekYear

$year = null, $dayOfWeek = null, $dayOfYear = null
returns int|Carbon

Set/get the week number of year using given first day of week and first day of year included in the first week. Or use ISO format if no settings given.

Method added2.0.0$year = null, $dayOfWeek = null, $dayOfYear = null

Carbon::weekYear

$year = null, $dayOfWeek = null, $dayOfYear = null
returns int|Carbon

Set/get the week number of year using given first day of week and first day of year included in the first week. Or use US format if no settings given (Sunday / Jan 6).

Method added2.0.0$year = null, $dayOfWeek = null, $dayOfYear = null

Carbon::isoWeeksInYear

$dayOfWeek = null, $dayOfYear = null
returns int

Get the number of weeks of the current week-year using given first day of week and first day of year included in the first week. Or use ISO format if no settings given.

Method added2.0.0$dayOfWeek = null, $dayOfYear = null

Carbon::weeksInYear

$dayOfWeek = null, $dayOfYear = null
returns int

Get the number of weeks of the current week-year using given first day of week and first day of year included in the first week. Or use US format if no settings given (Sunday / Jan 6).

Method added2.0.0$dayOfWeek = null, $dayOfYear = null

Carbon::week

$week = null, $dayOfWeek = null, $dayOfYear = null
returns int|Carbon

Get/set the week number using given first day of week and first day of year included in the first week. Or use US format if no settings given (Sunday / Jan 6).

Method added2.0.0$week = null, $dayOfWeek = null, $dayOfYear = null

Carbon::isoWeek

$week = null, $dayOfWeek = null, $dayOfYear = null
returns int|Carbon

Get/set the week number using given first day of week and first day of year included in the first week. Or use ISO format if no settings given.

Method added2.0.0$week = null, $dayOfWeek = null, $dayOfYear = null

Carbon::normalizeDay

Requires cmixin/business-time
no arguments
returns string

Returns day English name in lower case.

Carbon::convertOpeningHours

Requires cmixin/business-time
no arguments
returns Spatie\OpeningHours\OpeningHours

Returns an OpeningHours instance (the one given if already an instance of OpeningHours, or else create a new one from array definition given).

Carbon::enable

Requires cmixin/business-time
no arguments

Carbon::setOpeningHours

Requires cmixin/business-time
no arguments
returns $this|null

Set the opening hours for the class/instance.

Carbon::resetOpeningHours

Requires cmixin/business-time
no arguments
returns $this|null

Reset the opening hours for the class/instance.

Carbon::getOpeningHours

Requires cmixin/business-time
no arguments
returns Spatie\OpeningHours\OpeningHours

Get the opening hours of the class/instance.

Carbon::safeCallOnOpeningHours

Requires cmixin/business-time
no arguments
returns mixed

Call a method on the OpeningHours of the current instance.

Carbon::getCalleeAsMethod

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|bool

Get a closure to be executed on OpeningHours on the current instance (or now if called globally) that should return a date, then convert it into a Carbon/sub-class instance.

Carbon::getMethodLoopOnHoliday

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Loop on the current instance (or now if called statically) with a given method until it's not a holiday.

Carbon::getTernaryMethod

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::addBusinessDays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Add a given number of business days to the current date.

Carbon::addBusinessDay

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Add a given number of business days to the current date.

Carbon::subBusinessDays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Add a given number of business days to the current date.

Carbon::subtractBusinessDays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Add a given number of business days to the current date.

Carbon::subBusinessDay

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Add a given number of business days to the current date.

Carbon::subtractBusinessDay

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Add a given number of business days to the current date.

Carbon::diffInBusinessDays

Requires cmixin/business-time
no arguments
returns int

Returns the difference between 2 dates in business days.

Carbon::getBusinessDaysInMonth

Requires cmixin/business-time
no arguments
returns int

Get the number of business days in the current month.

Carbon::getMonthBusinessDays

Requires cmixin/business-time
no arguments
returns array

Get list of date objects for each business day in the current month.

Carbon::setBusinessDayChecker

Requires cmixin/business-time
no arguments
returns $this|null

Checks the date to see if it is a business day (neither a weekend day nor a holiday).

Carbon::isBusinessDay

Requires cmixin/business-time
no arguments
returns bool

Checks the date to see if it is a business day (extra workday or neither a weekend day nor a holiday).

Carbon::nextBusinessDay

Requires cmixin/business-time
no arguments
returns CarbonInterface|Carbon|CarbonImmutable

Sets the date to the next business day (neither a weekend day nor a holiday).

Carbon::currentOrNextBusinessDay

Requires cmixin/business-time
no arguments
returns CarbonInterface|Carbon|CarbonImmutable

Sets the date to the current or next business day (neither a weekend day nor a holiday).

Carbon::previousBusinessDay

Requires cmixin/business-time
no arguments
returns CarbonInterface|Carbon|CarbonImmutable

Sets the date to the next business day (neither a weekend day nor a holiday).

Carbon::currentOrPreviousBusinessDay

Requires cmixin/business-time
no arguments
returns CarbonInterface|Carbon|CarbonImmutable

Sets the date to the current or next business day (neither a weekend day nor a holiday).

Carbon::setObservedHolidaysZone

Requires cmixin/business-time
no arguments
returns $this|null

Set the selected zone for observed holidays. So next observe methods will be saved and considered in this given custom zone.

Carbon::getObservedHolidaysZone

Requires cmixin/business-time
no arguments
returns string|null

Get the selected zone for observed holidays.

Carbon::setHolidayObserveStatus

Requires cmixin/business-time
no arguments
returns $this|null

Set a holiday as observed/unobserved in the selected zone.

Carbon::getObserveHolidayMethod

Requires cmixin/business-time
no arguments
returns $this|null

Set a holiday as observed/unobserved in the selected zone (can take array of holidays).

Carbon::observeHoliday

Requires cmixin/business-time
no arguments
returns $this|null

Set a holiday as observed/unobserved in the selected zone (can take array of holidays).

Carbon::unobserveHoliday

Requires cmixin/business-time
no arguments
returns $this|null

Set a holiday as observed/unobserved in the selected zone (can take array of holidays).

Carbon::observeHolidays

Requires cmixin/business-time
no arguments
returns $this|null

Set a holiday as observed/unobserved in the selected zone (can take array of holidays).

Carbon::unobserveHolidays

Requires cmixin/business-time
no arguments
returns $this|null

Set a holiday as observed/unobserved in the selected zone (can take array of holidays).

Carbon::observeAllHolidays

Requires cmixin/business-time
no arguments
returns $this|null

Set a holiday as observed/unobserved in the selected zone (can take array of holidays).

Carbon::unobserveAllHolidays

Requires cmixin/business-time
no arguments
returns $this|null

Set a holiday as observed/unobserved in the selected zone (can take array of holidays).

Carbon::checkObservedHoliday

Requires cmixin/business-time
no arguments
returns bool

Check if a given holiday ID is observed in the selected zone.

Carbon::isObservedHoliday

Requires cmixin/business-time
no arguments
returns bool

Checks the date to see if it is a holiday observed in the selected zone.

Carbon::setHolidayGetter

Requires cmixin/business-time
no arguments
returns $this|null

Set the strategy to get the holiday ID from a date object.

Carbon::setExtraWorkdayGetter

Requires cmixin/business-time
no arguments
returns $this|null

Set the strategy to get the extra workday ID from a date object.

Carbon::getDBDayId

Requires cmixin/business-time
no arguments
returns string|false

Get the identifier of the current holiday or false if it's not a holiday.

Carbon::getHolidayId

Requires cmixin/business-time
no arguments
returns string|false

Get the identifier of the current holiday or false if it's not a holiday.

Carbon::isHoliday

Requires cmixin/business-time
no arguments
returns bool

Checks the date to see if it is a holiday.

Carbon::getExtraWorkdayId

Requires cmixin/business-time
no arguments
returns string|false

Get the identifier of the current special workday or false if it's not a special workday.

Carbon::isExtraWorkday

Requires cmixin/business-time
no arguments
returns bool

Checks the date to see if it is a holiday.

Carbon::getHolidayNamesDictionary

Requires cmixin/business-time
no arguments
returns array

Get the holidays in the given language.

Carbon::getHolidayName

Requires cmixin/business-time
no arguments
returns string|false

Get the name of the current holiday (using the locale given in parameter or the current date locale) or false if it's not a holiday.

Carbon::getYearHolidays

Requires cmixin/business-time
no arguments
returns array

Get the holidays dates for a given year (current year if no parameter given).

Carbon::getYearHolidaysNextFunction

Requires cmixin/business-time
no arguments
returns callable

Get a next() callback to call to iterate over holidays of a year.

Carbon::standardizeHolidaysRegion

Requires cmixin/business-time
no arguments
returns string

Return a standardized region name.

Carbon::getHolidaysAvailableRegions

Requires cmixin/business-time
no arguments
returns array

Get the current holidays region.

Carbon::setHolidaysRegion

Requires cmixin/business-time
no arguments

Set the holidays region (see src/Cmixin/Holidays for examples).

Carbon::getHolidaysRegion

Requires cmixin/business-time
no arguments
returns null|string

Get the current holidays region.

Carbon::getBDDaysList

Requires cmixin/business-time
no arguments
returns array

Get the holidays for the current region selected.

Carbon::getHolidays

Requires cmixin/business-time
no arguments
returns array

Get the holidays for the current region selected.

Carbon::setHolidays

Requires cmixin/business-time
no arguments

Set the holidays list.

Carbon::getExtraWorkdays

Requires cmixin/business-time
no arguments
returns array

Get the holidays for the current region selected.

Carbon::setExtraWorkdays

Requires cmixin/business-time
no arguments

Set the holidays list.

Carbon::resetHolidays

Requires cmixin/business-time
no arguments

Reset the holidays list.

Carbon::initializeHolidaysRegion

Requires cmixin/business-time
no arguments

Carbon::pushToBDList

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|null

Push a day into a given list list of a region.

Carbon::pushHoliday

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|null

Push a holiday to the holidays list of a region.

Carbon::pushWorkday

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|null

Push a workday to the workdays list of a region.

Carbon::setHolidayName

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|null

Set/change the name of holiday by ID for a given language (or a list of languages).

Carbon::addHoliday

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|null

Add a holiday to the holidays list of a region and optionally init its ID, name and observed state.

Carbon::addExtraWorkday

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|null

Add a workday to the workdays list of a region and optionally init its ID and name.

Carbon::unpackHoliday

Requires cmixin/business-time
no arguments
returns array

Unpack a holiday array definition.

Carbon::checkHoliday

Requires cmixin/business-time
no arguments
returns array

Check a holiday definition and unpack it if it's an array.

Carbon::addHolidays

Requires cmixin/business-time
no arguments

Add a holiday to the holidays list of a region and optionally init their IDs, names and observed states (if provided as array-definitions).

Carbon::isDateTimeInstance

Requires cmixin/business-time
no arguments
returns bool

Return true if the given value is a DateTime or DateTimeInterface.

Carbon::swapDateTimeParam

Requires cmixin/business-time
no arguments
returns array

Store a first variable as Carbon instance into the second variable if the first one is a date.

Carbon::skipMissingCalendarExtensionException

Requires cmixin/business-time
no arguments

@codeCoverageIgnore

Carbon::shouldRaiseMissingCalendarExtensionException

Requires cmixin/business-time
no arguments
returns bool

Carbon::getHolidayDataById

Requires cmixin/business-time
no arguments
returns array

Get stored data set for the a given holiday ID.

Carbon::setHolidayDataById

Requires cmixin/business-time
no arguments
returns $this|null

Set stored data set for the a given holiday ID.

Carbon::getHolidayData

Requires cmixin/business-time
no arguments
returns array

Get stored data set for the current holiday or null if it's not a holiday.

Carbon::setHolidayData

Requires cmixin/business-time
no arguments
returns $this|null

Set stored data set for the current holiday, does nothing if it's not a holiday.

Carbon::setMaxIteration

Requires cmixin/business-time
no arguments

Set the maximum of loop turns to run before throwing an exception where trying to add or subtract open/closed time.

Carbon::getMaxIteration

Requires cmixin/business-time
no arguments
returns int

Get the maximum of loop turns to run before throwing an exception where trying to add or subtract open/closed time.

Carbon::applyBusinessInterval

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Shift current time with a given interval taking into account only open time (if $open is true) or only closed time (if $open is false).

Carbon::addBusinessInterval

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Add the given interval taking into account only open time (if $open is true) or only closed time (if $open is false).

Carbon::subBusinessInterval

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Add the given interval taking into account only open time (if $open is true) or only closed time (if $open is false).

Carbon::addOpenTime

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Add the given interval taking into account only open time.

Carbon::subOpenTime

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Subtract the given interval taking into account only open time.

Carbon::addClosedTime

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Add the given interval taking into account only closed time.

Carbon::subClosedTime

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Subtract the given interval taking into account only closed time.

Carbon::addOpenMinutes

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Add the given number of minutes taking into account only open time.

Carbon::subOpenMinutes

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Subtract the given number of minutes taking into account only open time.

Carbon::addClosedMinutes

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Add the given number of minutes taking into account only closed time.

Carbon::subClosedMinutes

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Subtract the given number of minutes taking into account only closed time.

Carbon::addOpenHours

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Add the given number of hours taking into account only open time.

Carbon::subOpenHours

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Subtract the given number of hours taking into account only open time.

Carbon::addClosedHours

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Add the given number of hours taking into account only closed time.

Carbon::subClosedHours

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Subtract the given number of hours taking into account only closed time.

Carbon::closedOrNextOpenExcludingHolidays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::closedOrNextBusinessOpen

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::closedOrPreviousBusinessOpen

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::closedOrPreviousOpenExcludingHolidays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::closedOrNextOpen

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::closedOrPreviousOpen

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::currentOrNextOpenExcludingHolidays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::currentOrNextBusinessOpen

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::currentOrPreviousBusinessOpen

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::currentOrPreviousOpenExcludingHolidays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::currentOrNextCloseIncludingHolidays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::currentOrNextBusinessClose

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::currentOrPreviousCloseIncludingHolidays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::currentOrPreviousBusinessClose

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::currentOrNextOpen

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::currentOrPreviousOpen

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::currentOrNextClose

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::currentOrPreviousClose

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::diffInBusinessUnit

Requires cmixin/business-time
no arguments
returns CarbonInterval|float

Return an interval/count of given unit with open/closed business time between the current date and an other given date.

Carbon::diffAsBusinessInterval

Requires cmixin/business-time
no arguments
returns CarbonInterval

Return an interval with open/closed business time between the current date and an other given date.

Carbon::diffInBusinessSeconds

Requires cmixin/business-time
no arguments
returns float

Return a number of seconds with open/closed business time between the current date and an other given date.

Carbon::diffInBusinessMinutes

Requires cmixin/business-time
no arguments
returns float

Return a number of minutes with open/closed business time between the current date and an other given date.

Carbon::diffInBusinessHours

Requires cmixin/business-time
no arguments
returns float

Return a number of hours with open/closed business time between the current date and an other given date.

Carbon::nextOpenExcludingHolidays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Loop on the current instance (or now if called statically) with a given method until it's not a holiday.

Carbon::nextBusinessOpen

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Loop on the current instance (or now if called statically) with a given method until it's not a holiday.

Carbon::previousOpenExcludingHolidays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Loop on the current instance (or now if called statically) with a given method until it's not a holiday.

Carbon::previousBusinessOpen

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Loop on the current instance (or now if called statically) with a given method until it's not a holiday.

Carbon::nextCloseIncludingHolidays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Loop on the current instance (or now if called statically) with a given method until it's not a holiday.

Carbon::nextBusinessClose

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Loop on the current instance (or now if called statically) with a given method until it's not a holiday.

Carbon::previousCloseIncludingHolidays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Loop on the current instance (or now if called statically) with a given method until it's not a holiday.

Carbon::previousBusinessClose

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Loop on the current instance (or now if called statically) with a given method until it's not a holiday.

Carbon::isOpenOn

Requires cmixin/business-time
no arguments
returns bool

Returns true if the business is open on a given day according to current opening hours.

Carbon::isClosedOn

Requires cmixin/business-time
no arguments
returns bool

Returns true if the business is open on a given day according to current opening hours.

Carbon::isOpen

Requires cmixin/business-time
no arguments
returns bool

Returns true if the business is open now (or current date and time) according to current opening hours. /!\ Important: it returns true if the current day is a holiday unless you set a closure handler for it in the exceptions setting.

Carbon::isClosed

Requires cmixin/business-time
no arguments
returns bool

Returns true if the business is open now (or current date and time) according to current opening hours. /!\ Important: it returns true if the current day is a holiday unless you set a closure handler for it in the exceptions setting.

Carbon::isBusinessOpen

Requires cmixin/business-time
no arguments
returns bool

Returns true if the business is open and not a holiday now (or current date and time) according to current opening hours.

Carbon::isOpenExcludingHolidays

Requires cmixin/business-time
no arguments
returns bool

Returns true if the business is open and not a holiday now (or current date and time) according to current opening hours.

Carbon::isBusinessClosed

Requires cmixin/business-time
no arguments
returns bool

Returns true if the business is closed or a holiday now (or current date and time) according to current opening hours.

Carbon::isClosedIncludingHolidays

Requires cmixin/business-time
no arguments
returns bool

Returns true if the business is closed or a holiday now (or current date and time) according to current opening hours.

Carbon::nextOpen

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|bool

Get a closure to be executed on OpeningHours on the current instance (or now if called globally) that should return a date, then convert it into a Carbon/sub-class instance.

Carbon::nextClose

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|bool

Get a closure to be executed on OpeningHours on the current instance (or now if called globally) that should return a date, then convert it into a Carbon/sub-class instance.

Carbon::previousOpen

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|bool

Get a closure to be executed on OpeningHours on the current instance (or now if called globally) that should return a date, then convert it into a Carbon/sub-class instance.

Carbon::previousClose

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|bool

Get a closure to be executed on OpeningHours on the current instance (or now if called globally) that should return a date, then convert it into a Carbon/sub-class instance.

Carbon::openOrNextCloseIncludingHolidays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::openOrNextBusinessClose

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::openOrPreviousCloseIncludingHolidays

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::openOrPreviousBusinessClose

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::openOrNextClose

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::openOrPreviousClose

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface

Get a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.

Carbon::getCurrentDayOpeningHours

Requires cmixin/business-time
no arguments
returns Spatie\OpeningHours\OpeningHoursForDay

Get OpeningHoursForDay instance of the current instance or class.

Carbon::getCurrentOpenTimeRanges

Requires cmixin/business-time
no arguments
returns Spatie\OpeningHours\TimeRange[]

Get open time ranges as array of TimeRange instances that matches the current date and time.

Carbon::getCurrentOpenTimeRange

Requires cmixin/business-time
no arguments
returns Spatie\OpeningHours\TimeRange|bool

Get current open time range as TimeRange instance or false if closed.

Carbon::getCurrentOpenTimePeriod

Requires cmixin/business-time
no arguments
returns CarbonPeriod|bool

Get current open time range as TimeRange instance or false if closed.

Carbon::getCurrentOpenTimeRangeStart

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|bool

Get a closure to be executed on OpeningHours on the current instance (or now if called globally) that should return a date, then convert it into a Carbon/sub-class instance.

Carbon::getCurrentOpenTimeRangeEnd

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|bool

Get a closure to be executed on OpeningHours on the current instance (or now if called globally) that should return a date, then convert it into a Carbon/sub-class instance.

Carbon::getCurrentBusinessTimeRangeStart

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|bool

Get a closure to be executed on OpeningHours on the current instance (or now if called globally) that should return a date, then convert it into a Carbon/sub-class instance.

Carbon::getCurrentBusinessOpenTimeRangeEnd

Requires cmixin/business-time
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|bool

Get a closure to be executed on OpeningHours on the current instance (or now if called globally) that should return a date, then convert it into a Carbon/sub-class instance.

Carbon::setSeasonConfig

Requires cmixin/season
no arguments

Carbon::getSeason

Requires cmixin/season
no arguments
returns Season\SeasonEnum

Return the season of the current date.

Carbon::isInSpring

Requires cmixin/season
no arguments
returns bool

Return either current date is in spring.

Carbon::isInSummer

Requires cmixin/season
no arguments
returns bool

Return either current date is in summer.

Carbon::isInFall

Requires cmixin/season
no arguments
returns bool

Return either current date is in fall.

Carbon::isInWinter

Requires cmixin/season
no arguments
returns bool

Return either current date is in winter.

Carbon::startOfSeason

Requires cmixin/season
no arguments
returns Carbon

Carbon::endOfSeason

Requires cmixin/season
no arguments
returns Carbon

CarbonInterval::setTimezone

DateTimeZone|string|int $timezone
returns CarbonInterval

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

Prototype changed3.0.0DateTimeZone|string|int $timezone
Method added2.52.0$tzName

CarbonInterval::shiftTimezone

DateTimeZone|string|int $timezone
returns CarbonInterval

Set the instance's timezone from a string or object and add/subtract the offset difference.

Prototype changed3.0.0DateTimeZone|string|int $timezone
Method added2.3.0$tzName

CarbonInterval::getCascadeFactors

no arguments
returns array

Mapping of units and factors for cascading.

Should only be modified by changing the factors or referenced constants.

Method added1.28.0no arguments

CarbonInterval::setCascadeFactors

array $cascadeFactors

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

Method added1.28.0array $cascadeFactors

CarbonInterval::enableFloatSetters

bool $floatSettersEnabled = true

This option allow you to opt-in for the Carbon 3 behavior where float values will no longer be cast to integer (so truncated).

⚠️ 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.

Method added2.70.0bool $floatSettersEnabled = true

CarbonInterval::__construct

$years = null, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null, $microseconds = null

Create a new CarbonInterval instance.

Prototype changed3.0.0$years = null, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null, $microseconds = null
Prototype changed2.0.0$years = 1, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null, $microseconds = null
Method added1.18.0$years = 1, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null

CarbonInterval::getFactor

$source, $target
returns int|float|null

Returns the factor for a given source-to-target couple.

Method added1.28.0$source, $target

CarbonInterval::getFactorWithDefault

$source, $target
returns 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.

Method added2.55.0$source, $target

CarbonInterval::getDaysPerWeek

no arguments
returns int|float

Returns current config for days per week.

Method added1.28.0no arguments

CarbonInterval::getHoursPerDay

no arguments
returns int|float

Returns current config for hours per day.

Method added1.28.0no arguments

CarbonInterval::getMinutesPerHour

no arguments
returns int|float

Returns current config for minutes per hour.

Method added2.0.0no arguments

CarbonInterval::getSecondsPerMinute

no arguments
returns int|float

Returns current config for seconds per minute.

Method added2.0.0no arguments

CarbonInterval::getMillisecondsPerSecond

no arguments
returns int|float

Returns current config for microseconds per second.

Method added2.0.0no arguments

CarbonInterval::getMicrosecondsPerMillisecond

no arguments
returns int|float

Returns current config for microseconds per second.

Method added2.0.0no arguments

CarbonInterval::create

$years = null, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null, $microseconds = null
returns CarbonInterval

Create a new CarbonInterval instance from specific values. 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().

Prototype changed3.0.0$years = null, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null, $microseconds = null
Prototype changed2.5.0$years = 1, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null, $microseconds = null
Method added1.18.0$years = 1, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null

CarbonInterval::createFromFormat

string $format, ?string $interval
returns CarbonInterval

Parse a string into a new CarbonInterval object according to the specified format.

Examples:

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

Method added2.27.0string $format, ?string $interval

CarbonInterval::original

no arguments
returns array|int|string|DateInterval|mixed|null

Return the original source used to create the current interval.

Method added3.0.0no arguments

CarbonInterval::start

no arguments
returns CarbonInterface

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

Method added3.0.0no arguments

CarbonInterval::end

no arguments
returns CarbonInterface

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

Method added3.0.0no arguments

CarbonInterval::optimize

no arguments
returns CarbonInterval

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

Method added3.0.0no arguments

CarbonInterval::copy

no arguments
returns CarbonInterval

Get a copy of the instance.

Method added1.28.0no arguments

CarbonInterval::clone

no arguments
returns CarbonInterval

Get a copy of the instance.

Method added2.22.0no arguments

CarbonInterval::__set_state

$dump
returns CarbonInterval

Evaluate the PHP generated by var_export() and recreate the exported CarbonInterval instance.

Prototype changed2.71.0$dump
Method added1.18.0array $array

CarbonInterval::fromString

string $intervalDefinition
returns CarbonInterval

Creates a CarbonInterval from string.

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)

Prototype changed3.0.0string $intervalDefinition
Method added1.25.0$intervalDefinition

CarbonInterval::parseFromLocale

string $interval, ?string $locale = null
returns CarbonInterval

Creates a CarbonInterval from string using a different locale.

Prototype changed3.0.0string $interval, ?string $locale = null
Prototype changed2.35.0$interval, $locale = null
Method added2.21.0$interval, $locale

CarbonInterval::diff

$start, $end = null, bool $absolute = false, array $skip = []
returns CarbonInterval

Create an interval from the difference between 2 dates.

Method added3.0.0$start, $end = null, bool $absolute = false, array $skip = []

CarbonInterval::abs

bool $absolute = false
returns CarbonInterval

Invert the interval if it's inverted.

Method added3.0.0bool $absolute = false

CarbonInterval::absolute

bool $absolute = true
returns CarbonInterval

@alias abs

Invert the interval if it's inverted.

Method added3.0.0bool $absolute = true

CarbonInterval::cast

string $className
returns mixed

Cast the current instance into the given class.

Method added2.23.0string $className

CarbonInterval::instance

DateInterval $interval, array $skip = [], bool $skipCopy = false
returns CarbonInterval

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.

Prototype changed2.70.0DateInterval $interval, array $skip = [], bool $skipCopy = false
Prototype changed2.64.0DateInterval $interval, array $skip = []
Prototype changed2.21.0DateInterval $interval
Prototype changed2.0.0DateInterval $di
Prototype changed1.35.0DateInterval $di, $trimMicroseconds = true
Method added1.18.0DateInterval $di

CarbonInterval::make

$interval, $unit = null, bool $skipCopy = false
returns CarbonInterval

Make a CarbonInterval instance from given variable if possible.

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.

Prototype changed2.70.0$interval, $unit = null, bool $skipCopy = false
Prototype changed2.34.0$interval, $unit = null
Method added1.28.0$var

CarbonInterval::createFromDateString

string $datetime
returns CarbonInterval

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

Prototype changed3.0.0string $datetime
Prototype changed2.0.0$time
Prototype changed1.37.1string $datetime
Method added1.18.0$time

CarbonInterval::get

Carbon\Unit|string $name
returns string|int|float|null

Get a part of the CarbonInterval object.

Prototype changed3.1.0Carbon\Unit|string $name
Prototype changed3.0.0string $name
Method added2.37.0$name

CarbonInterval::__get

string $name
returns string|int|float|null

Get a part of the CarbonInterval object.

Prototype changed3.0.0string $name
Method added1.18.0$name

CarbonInterval::set

$name, $value = null
returns CarbonInterval

Set a part of the CarbonInterval object.

Method added2.37.0$name, $value = null

CarbonInterval::__set

string $name, $value

Set a part of the CarbonInterval object.

Prototype changed3.0.0string $name, $value
Prototype changed2.0.0$name, $value
Method added1.18.0$name, $val

CarbonInterval::weeksAndDays

int $weeks, int $days
returns CarbonInterval

Allow setting of weeks and days to be cumulative.

Prototype changed3.0.0int $weeks, int $days
Method added1.18.0$weeks, $days

CarbonInterval::isEmpty

no arguments
returns bool

Returns true if the interval is empty for each unit.

Method added2.0.0no arguments

CarbonInterval::macro

string $name, ?callable $macro

Register a custom macro.

Pass null macro to remove it.

Examples:

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

Prototype changed3.0.1string $name, ?callable $macro
Prototype changed3.0.0string $name, $macro
Method added1.28.0$name, $macro

CarbonInterval::mixin

$mixin

Register macros from a mixin object.

Examples:

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";

Method added1.28.0$mixin

CarbonInterval::hasMacro

string $name
returns bool

Check if macro is registered.

Prototype changed3.0.0string $name
Method added1.28.0$name

CarbonInterval::toArray

no arguments
returns array

Returns interval values as an array where key are the unit names and values the counts.

Method added2.27.0no arguments

CarbonInterval::getNonZeroValues

no arguments
returns array

Returns interval non-zero values as an array where key are the unit names and values the counts.

Method added2.27.0no arguments

CarbonInterval::getValuesSequence

no arguments
returns array

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.

Method added2.27.0no arguments

CarbonInterval::forHumans

$syntax = null, $short = false, $parts = -1, $options = null
returns string

Get the current interval in a human readable format in the current locale.

Examples:

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";

Prototype changed2.0.0$syntax = null, $short = false, $parts = -1, $options = null
Prototype changed1.28.0$short = false
Method added1.18.0no arguments

CarbonInterval::format

string $format
returns string

Returns the formatted date string on success or FALSE on failure.

Prototype changed1.37.1string $format
Method added1.18.0$format

CarbonInterval::__toString

no arguments
returns string

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

Method added1.18.0no arguments

CarbonInterval::toDateInterval

no arguments
returns DateInterval

Return native DateInterval PHP object matching the current instance.

Examples:

\Carbon\Doc\Generate\var_dump(CarbonInterval::hours(2)->toDateInterval());

Method added2.23.0no arguments

CarbonInterval::toPeriod

$params
returns CarbonPeriod

Convert the interval to a CarbonPeriod.

Prototype changed2.0.0$params
Method added1.29.0no arguments

CarbonInterval::stepBy

$interval, Carbon\Unit|string|null $unit = null
returns CarbonPeriod

Decompose the current interval into

Method added3.0.0$interval, Carbon\Unit|string|null $unit = null

CarbonInterval::invert

$inverted = null
returns CarbonInterval

Invert the interval.

Prototype changed2.37.0$inverted = null
Method added1.28.0no arguments

CarbonInterval::add

$unit, $value = 1
returns CarbonInterval

Add the passed interval to the current instance.

Prototype changed2.4.0$unit, $value = 1
Method added1.18.0DateInterval $interval

CarbonInterval::sub

$unit, $value = 1
returns CarbonInterval

Subtract the passed interval to the current instance.

Method added2.4.0$unit, $value = 1

CarbonInterval::subtract

$unit, $value = 1
returns CarbonInterval

Subtract the passed interval to the current instance.

Method added2.4.0$unit, $value = 1

CarbonInterval::plus

$years = 0, $months = 0, $weeks = 0, $days = 0, $hours = 0, $minutes = 0, $seconds = 0, $microseconds = 0
returns CarbonInterval

Add given parameters to the current interval.

Method added2.45.0$years = 0, $months = 0, $weeks = 0, $days = 0, $hours = 0, $minutes = 0, $seconds = 0, $microseconds = 0

CarbonInterval::minus

$years = 0, $months = 0, $weeks = 0, $days = 0, $hours = 0, $minutes = 0, $seconds = 0, $microseconds = 0
returns CarbonInterval

Add given parameters to the current interval.

Method added2.45.0$years = 0, $months = 0, $weeks = 0, $days = 0, $hours = 0, $minutes = 0, $seconds = 0, $microseconds = 0

CarbonInterval::times

$factor
returns CarbonInterval

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.

Use times() when you want a fast and approximated calculation that does not cascade units.

For a precise and cascaded calculation,

Method added1.27.0$factor

CarbonInterval::shares

$divider
returns CarbonInterval

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.

Use shares() when you want a fast and approximated calculation that does not cascade units.

For a precise and cascaded calculation,

Method added2.20.0$divider

CarbonInterval::multiply

$factor
returns CarbonInterval

Multiply and cascade current instance by a given factor.

Method added2.20.0$factor

CarbonInterval::divide

$divider
returns CarbonInterval

Divide and cascade current instance by a given divider.

Method added2.20.0$divider

CarbonInterval::getDateIntervalSpec

DateInterval $interval, bool $microseconds = false, array $skip = []
returns string

Get the interval_spec string of a date interval.

Prototype changed2.64.0DateInterval $interval, bool $microseconds = false, array $skip = []
Prototype changed2.61.0DateInterval $interval, bool $microseconds = false
Method added1.26.0DateInterval $interval

CarbonInterval::spec

bool $microseconds = false
returns string

Get the interval_spec string.

Prototype changed2.61.0bool $microseconds = false
Method added1.22.0no arguments

CarbonInterval::compareDateIntervals

DateInterval $first, DateInterval $second
returns int

Comparing 2 date intervals.

Prototype changed2.21.0DateInterval $first, DateInterval $second
Method added1.26.0DateInterval $a, DateInterval $b

CarbonInterval::compare

DateInterval $interval
returns int

Comparing with passed interval.

Method added1.24.0DateInterval $interval

CarbonInterval::cascade

no arguments
returns CarbonInterval

Convert overflowed values into bigger units.

Method added1.28.0no arguments

CarbonInterval::hasNegativeValues

no arguments
returns bool

Method added2.37.0no arguments

CarbonInterval::hasPositiveValues

no arguments
returns bool

Method added2.37.0no arguments

CarbonInterval::total

string $unit
returns float

Get amount of given unit equivalent to the interval.

Prototype changed3.0.0string $unit
Method added1.28.0$unit

CarbonInterval::eq

$interval
returns bool

Determines if the instance is equal to another

Method added2.22.0$interval

CarbonInterval::equalTo

$interval
returns bool

Determines if the instance is equal to another

Method added2.22.0$interval

CarbonInterval::ne

$interval
returns bool

Determines if the instance is not equal to another

Method added2.22.0$interval

CarbonInterval::notEqualTo

$interval
returns bool

Determines if the instance is not equal to another

Method added2.22.0$interval

CarbonInterval::gt

$interval
returns bool

Determines if the instance is greater (longer) than another

Method added2.22.0$interval

CarbonInterval::greaterThan

$interval
returns bool

Determines if the instance is greater (longer) than another

Method added2.22.0$interval

CarbonInterval::gte

$interval
returns bool

Determines if the instance is greater (longer) than or equal to another

Method added2.22.0$interval

CarbonInterval::greaterThanOrEqualTo

$interval
returns bool

Determines if the instance is greater (longer) than or equal to another

Method added2.22.0$interval

CarbonInterval::lt

$interval
returns bool

Determines if the instance is less (shorter) than another

Method added2.22.0$interval

CarbonInterval::lessThan

$interval
returns bool

Determines if the instance is less (shorter) than another

Method added2.22.0$interval

CarbonInterval::lte

$interval
returns bool

Determines if the instance is less (shorter) than or equal to another

Method added2.22.0$interval

CarbonInterval::lessThanOrEqualTo

$interval
returns bool

Determines if the instance is less (shorter) than or equal to another

Method added2.22.0$interval

CarbonInterval::between

$interval1, $interval2, bool $equal = true
returns bool

Determines if the instance is between two others.

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.

Examples:

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

Prototype changed3.0.0$interval1, $interval2, bool $equal = true
Method added2.22.0$interval1, $interval2, $equal = true

CarbonInterval::betweenIncluded

$interval1, $interval2
returns bool

Determines if the instance is between two others, bounds excluded.

Examples:

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

Method added2.31.0$interval1, $interval2

CarbonInterval::betweenExcluded

$interval1, $interval2
returns bool

Determines if the instance is between two others, bounds excluded.

Examples:

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

Method added2.22.0$interval1, $interval2

CarbonInterval::isBetween

$interval1, $interval2, bool $equal = true
returns bool

Determines if the instance is between two others

Examples:

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

Prototype changed3.0.0$interval1, $interval2, bool $equal = true
Method added2.22.0$interval1, $interval2, $equal = true

CarbonInterval::roundUnit

string $unit, DateInterval|string|int|float $precision = 1, string $function = 'round'
returns CarbonInterval

Round the current instance at the given unit with given precision if specified and the given function.

Prototype changed3.0.0string $unit, DateInterval|string|int|float $precision = 1, string $function = 'round'
Method added2.23.0$unit, $precision = 1, $function = 'round'

CarbonInterval::floorUnit

string $unit, $precision = 1
returns CarbonInterval

Truncate the current instance at the given unit with given precision if specified.

Prototype changed3.0.0string $unit, $precision = 1
Method added2.23.0$unit, $precision = 1

CarbonInterval::ceilUnit

string $unit, $precision = 1
returns CarbonInterval

Ceil the current instance at the given unit with given precision if specified.

Prototype changed3.0.0string $unit, $precision = 1
Method added2.23.0$unit, $precision = 1

CarbonInterval::round

$precision = 1, string $function = 'round'
returns CarbonInterval

Round the current instance second with given precision if specified.

Prototype changed3.0.0$precision = 1, string $function = 'round'
Method added2.23.0$precision = 1, $function = 'round'

CarbonInterval::floor

DateInterval|string|int|float $precision = 1
returns CarbonInterval

Round the current instance second with given precision if specified.

Prototype changed3.0.0DateInterval|string|int|float $precision = 1
Method added2.23.0$precision = 1

CarbonInterval::ceil

DateInterval|string|int|float $precision = 1
returns CarbonInterval

Ceil the current instance second with given precision if specified.

Prototype changed3.0.0DateInterval|string|int|float $precision = 1
Method added2.23.0$precision = 1

CarbonInterval::__serialize

Native PHP method
returns array

See PHP documentation for DateInterval::__serialize

CarbonInterval::__unserialize

Native PHP method

See PHP documentation for DateInterval::__unserialize

CarbonInterval::__wakeup

Native PHP method

See PHP documentation for DateInterval::__wakeup

CarbonInterval::getClock

no arguments
returns WrapperClock

Method added3.0.0no arguments

CarbonInterval::getStep

no arguments
returns Closure

Get the dynamic step in use.

Method added2.36.0no arguments

CarbonInterval::setStep

?Closure $step

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

Or pass null to switch to fixed interval.

Method added2.36.0?Closure $step

CarbonInterval::convertDate

DateTimeInterface $dateTime, bool $negated = false
returns CarbonInterface

Take a date and apply either the step if set, or the current interval else.

The interval/step is applied negatively (typically subtraction instead of addition) if $negated is true.

Method added2.36.0DateTimeInterface $dateTime, bool $negated = false

CarbonInterval::baseMixin

object|string $mixin

Mix another object into the class.

Examples:

Carbon::mixin(new class {
  public function addMoon() {
    return function () {
      return $this->addDays(30);
    };
  }
  public function subMoon() {
    return function () {
      return $this->subDays(30);
    };
  }
});
$fullMoon = Carbon::create('2018-12-22');
$nextFullMoon = $fullMoon->addMoon();
$blackMoon = Carbon::create('2019-01-06');
$previousBlackMoon = $blackMoon->subMoon();
echo "$nextFullMoon\n";
echo "$previousBlackMoon\n";

Prototype changed3.0.0object|string $mixin
Method added2.23.0$mixin

CarbonInterval::settings

array $settings
returns CarbonInterval

Set specific options. - 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

Method added2.0.0array $settings

CarbonInterval::getSettings

no arguments
returns array

Returns current local settings.

Method added2.3.0no arguments

CarbonInterval::__debugInfo

no arguments
returns array

Show truthy properties on \Carbon\Doc\Generate\var_dump().

Method added2.17.0no arguments

CarbonInterval::useStrictMode

bool $strictModeEnabled = true

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method.

Prototype changed3.0.0bool $strictModeEnabled = true
Method added2.0.0$strictModeEnabled = true

CarbonInterval::isStrictModeEnabled

no arguments
returns bool

Returns true if the strict mode is globally in use, false else. (It can be overridden in specific instances.)

Method added2.0.0no arguments

CarbonInterval::useMonthsOverflow

bool $monthsOverflow = true

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method. Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).

Prototype changed3.0.0bool $monthsOverflow = true
Method added2.0.0$monthsOverflow = true

CarbonInterval::resetMonthsOverflow

no arguments

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method. Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).

Method added2.0.0no arguments

CarbonInterval::shouldOverflowMonths

no arguments
returns bool

Get the month overflow global behavior (can be overridden in specific instances).

Method added2.0.0no arguments

CarbonInterval::useYearsOverflow

bool $yearsOverflow = true

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method. Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).

Prototype changed3.0.0bool $yearsOverflow = true
Method added2.0.0$yearsOverflow = true

CarbonInterval::resetYearsOverflow

no arguments

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method. Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).

Method added2.0.0no arguments

CarbonInterval::shouldOverflowYears

no arguments
returns bool

Get the month overflow global behavior (can be overridden in specific instances).

Method added2.0.0no arguments

CarbonInterval::hasLocalTranslator

no arguments
returns bool

Return true if the current instance has its own translator.

Method added2.29.0no arguments

CarbonInterval::getLocalTranslator

no arguments
returns Symfony\Contracts\Translation\TranslatorInterface

Get the translator of the current instance or the default if none set.

Method added2.0.0no arguments

CarbonInterval::setLocalTranslator

Symfony\Contracts\Translation\TranslatorInterface $translator
returns CarbonInterval

Set the translator for the current instance.

Prototype changed3.0.0Symfony\Contracts\Translation\TranslatorInterface $translator
Method added2.0.0Symfony\Component\Translation\TranslatorInterface $translator

CarbonInterval::getTranslationMessageWith

$translator, string $key, ?string $locale = null, ?string $default = null
returns string|Closure|null

Returns raw translation message for a given key.

Method added2.8.0$translator, string $key, ?string $locale = null, ?string $default = null

CarbonInterval::getTranslationMessage

string $key, ?string $locale = null, ?string $default = null, $translator = null
returns string

Returns raw translation message for a given key.

Method added2.8.0string $key, ?string $locale = null, ?string $default = null, $translator = null

CarbonInterval::translateWith

Symfony\Contracts\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null
returns string

Translate using translation string or callback available.

Prototype changed3.0.0Symfony\Contracts\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null
Method added2.8.0Symfony\Component\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null

CarbonInterval::translate

string $key, array $parameters = [], string|int|float|null $number = null, ?Symfony\Contracts\Translation\TranslatorInterface $translator = null, bool $altNumbers = false
returns string

Translate using translation string or callback available.

Prototype changed3.0.0string $key, array $parameters = [], string|int|float|null $number = null, ?Symfony\Contracts\Translation\TranslatorInterface $translator = null, bool $altNumbers = false
Prototype changed2.23.0string $key, array $parameters = [], $number = null, ?Symfony\Component\Translation\TranslatorInterface $translator = null, bool $altNumbers = false
Method added2.8.0string $key, array $parameters = [], $number = null, ?Symfony\Component\Translation\TranslatorInterface $translator = null

CarbonInterval::translateNumber

int $number
returns string

Returns the alternative number for a given integer if available in the current locale.

Method added2.23.0int $number

CarbonInterval::translateTimeString

string $timeString, ?string $from = null, ?string $to = null, int $mode = 31
returns string

Translate a time string from a locale to an other.

Prototype changed3.0.0string $timeString, ?string $from = null, ?string $to = null, int $mode = 31
Prototype changed2.35.0$timeString, $from = null, $to = null, $mode = 31
Method added2.16.0$timeString, $from = null, $to = null, $mode = 15

CarbonInterval::translateTimeStringTo

string $timeString, ?string $to = null
returns string

Translate a time string from the current locale (`$date->locale()`) to an other.

Prototype changed3.0.0string $timeString, ?string $to = null
Method added2.16.0$timeString, $to = null

CarbonInterval::locale

?string $locale = null, string $fallbackLocales
returns CarbonInterval|string

Get/set the locale for the current instance.

Prototype changed3.0.0?string $locale = null, string $fallbackLocales
Prototype changed2.16.0?string $locale = null, $fallbackLocales
Method added2.0.0?string $locale = null

CarbonInterval::getLocale

no arguments
returns string

Get the current translator locale.

Method added1.18.0no arguments

CarbonInterval::setLocale

string $locale

Set the current translator locale and indicate if the source locale file exists. Pass 'auto' as locale to use the closest language to the current LC_TIME locale.

Prototype changed3.0.0string $locale
Method added1.18.0$locale

CarbonInterval::setFallbackLocale

string $locale

Set the fallback locale.

Prototype changed3.0.0string $locale
Method added2.16.0$locale

CarbonInterval::getFallbackLocale

no arguments
returns string

Get the fallback locale.

Method added2.16.0no arguments

CarbonInterval::executeWithLocale

string $locale, callable $func
returns mixed

Set the current locale to the given, execute the passed function, reset the locale to previous one, then return the result of the closure (or null if the closure was void).

Prototype changed3.0.0string $locale, callable $func
Method added2.0.0$locale, $func

CarbonInterval::localeHasShortUnits

string $locale
returns bool

Returns true if the given locale is internally supported and has short-units support. Support is considered enabled if either year, day or hour has a short variant translated.

Prototype changed3.0.0string $locale
Method added2.0.0$locale

CarbonInterval::localeHasDiffSyntax

string $locale
returns bool

Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after). Support is considered enabled if the 4 sentences are translated in the given locale.

Prototype changed3.0.0string $locale
Method added2.0.0$locale

CarbonInterval::localeHasDiffOneDayWords

string $locale
returns bool

Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow). Support is considered enabled if the 3 words are translated in the given locale.

Prototype changed3.0.0string $locale
Method added2.0.0$locale

CarbonInterval::localeHasDiffTwoDayWords

string $locale
returns bool

Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow). Support is considered enabled if the 2 words are translated in the given locale.

Prototype changed3.0.0string $locale
Method added2.0.0$locale

CarbonInterval::localeHasPeriodSyntax

$locale
returns bool

Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X). Support is considered enabled if the 4 sentences are translated in the given locale.

Method added2.0.0$locale

CarbonInterval::getAvailableLocales

no arguments
returns array

Returns the list of internally available locales and already loaded custom locales. (It will ignore custom translator dynamic loading.)

Method added2.0.0no arguments

CarbonInterval::getAvailableLocalesInfo

no arguments
returns Language[]

Returns list of Language object for each available locale. This object allow you to get the ISO name, native name, region and variant of the locale.

Method added2.10.1no arguments

CarbonInterval::setHumanDiffOptions

int $humanDiffOptions

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method.

Prototype changed3.0.0int $humanDiffOptions
Method added2.0.0$humanDiffOptions

CarbonInterval::enableHumanDiffOption

int $humanDiffOption

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method.

Prototype changed3.0.0int $humanDiffOption
Method added2.0.0$humanDiffOption

CarbonInterval::disableHumanDiffOption

int $humanDiffOption

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method.

Prototype changed3.0.0int $humanDiffOption
Method added2.0.0$humanDiffOption

CarbonInterval::getHumanDiffOptions

no arguments
returns int

Return default humanDiff() options (merged flags as integer).

Method added2.0.0no arguments

CarbonInterval::setTranslator

Symfony\Contracts\Translation\TranslatorInterface $translator

Set the default translator instance to use.

Prototype changed3.0.0Symfony\Contracts\Translation\TranslatorInterface $translator
Method added1.18.0Symfony\Component\Translation\TranslatorInterface $translator

CarbonInterval::getTranslator

no arguments
returns Symfony\Contracts\Translation\TranslatorInterface

Initialize the default translator instance if necessary.

Method added1.18.0no arguments

CarbonInterval::resetToStringFormat

no arguments

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

Method added2.63.0no arguments

CarbonInterval::setToStringFormat

Closure|string|null $format

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.

Prototype changed3.0.0Closure|string|null $format
Method added2.63.0$format

CarbonPeriod::getIterator

no arguments
returns Generator

Method added3.0.0no arguments

CarbonPeriod::make

mixed $var
returns CarbonPeriod

Make a CarbonPeriod instance from given variable if possible.

Prototype changed3.0.0mixed $var
Method added2.22.0$var

CarbonPeriod::instance

mixed $period
returns CarbonPeriod

Create a new instance from a DatePeriod or CarbonPeriod object.

Prototype changed3.0.0mixed $period
Method added2.22.0$period

CarbonPeriod::create

$params
returns CarbonPeriod

Create a new instance.

Prototype changed2.0.0$params
Method added1.29.0no arguments

CarbonPeriod::createFromArray

array $params
returns CarbonPeriod

Create a new instance from an array of parameters.

Method added1.29.0array $params

CarbonPeriod::createFromIso

string $iso, ?int $options = null
returns CarbonPeriod

Create CarbonPeriod from ISO 8601 string.

Prototype changed3.0.0string $iso, ?int $options = null
Method added1.29.0$iso, $options = null

CarbonPeriod::macro

string $name, ?callable $macro

Register a custom macro.

Pass null macro to remove it.

Examples:

CarbonPeriod::macro('middle', function () {
  return $this->getStartDate()->average($this->getEndDate());
});
echo CarbonPeriod::since('2011-05-12')->until('2011-06-03')->middle();

Prototype changed3.0.1string $name, ?callable $macro
Prototype changed3.0.0string $name, $macro
Method added1.29.0$name, $macro

CarbonPeriod::mixin

object|string $mixin

Register macros from a mixin object.

Examples:

CarbonPeriod::mixin(new class {
  public function addDays() {
    return function ($count = 1) {
      return $this->setStartDate(
        $this->getStartDate()->addDays($count)
      )->setEndDate(
        $this->getEndDate()->addDays($count)
      );
    };
  }
  public function subDays() {
    return function ($count = 1) {
      return $this->setStartDate(
        $this->getStartDate()->subDays($count)
      )->setEndDate(
        $this->getEndDate()->subDays($count)
      );
    };
  }
});
echo CarbonPeriod::create('2000-01-01', '2000-02-01')->addDays(5)->subDays(3);

Prototype changed3.0.0object|string $mixin
Method added1.29.0$mixin

CarbonPeriod::hasMacro

string $name
returns bool

Check if macro is registered.

Prototype changed3.0.0string $name
Method added1.29.0$name

CarbonPeriod::__construct

$arguments

CarbonPeriod constructor.

Prototype changed2.0.0$arguments
Method added1.29.0no arguments

CarbonPeriod::copy

no arguments
returns CarbonPeriod

Get a copy of the instance.

Method added2.22.0no arguments

CarbonPeriod::get

string $name
returns bool|CarbonInterface|CarbonInterval|int|null

Get a property allowing both `DatePeriod` snakeCase and camelCase names.

Method added2.45.0string $name

CarbonPeriod::__get

string $name
returns bool|CarbonInterface|CarbonInterval|int|null

Get a property allowing both `DatePeriod` snakeCase and camelCase names.

Method added2.41.0string $name

CarbonPeriod::__isset

string $name
returns bool

Check if an attribute exists on the object

Method added2.41.0string $name

CarbonPeriod::clone

no arguments
returns CarbonPeriod

@alias copy

Get a copy of the instance.

Method added2.22.0no arguments

CarbonPeriod::setDateClass

string $dateClass
returns CarbonPeriod

Set the iteration item class.

Method added2.0.0string $dateClass

CarbonPeriod::getDateClass

no arguments
returns string

Returns iteration item date class.

Method added2.0.0no arguments

CarbonPeriod::setDateInterval

mixed $interval, Carbon\Unit|string|null $unit = null
returns CarbonPeriod

Change the period date interval.

Prototype changed3.0.0mixed $interval, Carbon\Unit|string|null $unit = null
Method added1.29.0$interval

CarbonPeriod::resetDateInterval

no arguments
returns CarbonPeriod

Reset the date interval to the default value.

Difference with simply setting interval to 1-day is that P1D will not appear when calling toIso8601String() and also next adding to the interval won't include the default 1-day.

Method added3.0.0no arguments

CarbonPeriod::invertDateInterval

no arguments
returns CarbonPeriod

Invert the period date interval.

Method added1.29.0no arguments

CarbonPeriod::setDates

mixed $start, mixed $end
returns CarbonPeriod

Set start and end date.

Prototype changed3.0.0mixed $start, mixed $end
Method added1.29.0$start, $end

CarbonPeriod::setOptions

?int $options
returns CarbonPeriod

Change the period options.

Prototype changed3.0.0?int $options
Method added1.29.0$options

CarbonPeriod::getOptions

no arguments
returns int

Get the period options.

Method added1.29.0no arguments

CarbonPeriod::toggleOptions

int $options, ?bool $state = null
returns CarbonPeriod

Toggle given options on or off.

Prototype changed3.0.0int $options, ?bool $state = null
Method added1.29.0$options, $state = null

CarbonPeriod::excludeStartDate

bool $state = true
returns CarbonPeriod

Toggle EXCLUDE_START_DATE option.

Prototype changed3.0.0bool $state = true
Method added1.29.0$state = true

CarbonPeriod::excludeEndDate

bool $state = true
returns CarbonPeriod

Toggle EXCLUDE_END_DATE option.

Prototype changed3.0.0bool $state = true
Method added1.29.0$state = true

CarbonPeriod::getDateInterval

no arguments
returns CarbonInterval

Get the underlying date interval.

Method added1.29.0no arguments

CarbonPeriod::getStartDate

?string $rounding = null
returns CarbonInterface

Get start date of the period.

Prototype changed2.23.0?string $rounding = null
Method added1.29.0no arguments

CarbonPeriod::getEndDate

?string $rounding = null
returns CarbonInterface

Get end date of the period.

Prototype changed2.23.0?string $rounding = null
Method added1.29.0no arguments

CarbonPeriod::getRecurrences

no arguments
returns int|float|null

Get number of recurrences.

Method added1.29.0no arguments

CarbonPeriod::isStartExcluded

no arguments
returns bool

Returns true if the start date should be excluded.

Method added1.29.0no arguments

CarbonPeriod::isEndExcluded

no arguments
returns bool

Returns true if the end date should be excluded.

Method added1.29.0no arguments

CarbonPeriod::isStartIncluded

no arguments
returns bool

Returns true if the start date should be included.

Method added2.23.0no arguments

CarbonPeriod::isEndIncluded

no arguments
returns bool

Returns true if the end date should be included.

Method added2.23.0no arguments

CarbonPeriod::getIncludedStartDate

no arguments
returns CarbonInterface

Return the start if it's included by option, else return the start + 1 period interval.

Method added2.23.0no arguments

CarbonPeriod::getIncludedEndDate

no arguments
returns CarbonInterface

Return the end if it's included by option, else return the end - 1 period interval. Warning: if the period has no fixed end, this method will iterate the period to calculate it.

Method added2.23.0no arguments

CarbonPeriod::addFilter

callable|string $callback, ?string $name = null
returns CarbonPeriod

Add a filter to the stack.

Prototype changed3.0.0callable|string $callback, ?string $name = null
Method added1.29.0$callback, $name = null

CarbonPeriod::prependFilter

callable|string $callback, ?string $name = null
returns CarbonPeriod

Prepend a filter to the stack.

Prototype changed3.0.0callable|string $callback, ?string $name = null
Method added1.29.0$callback, $name = null

CarbonPeriod::removeFilter

callable|string $filter
returns CarbonPeriod

Remove a filter by instance or name.

Prototype changed3.0.0callable|string $filter
Method added1.29.0$filter

CarbonPeriod::hasFilter

callable|string $filter
returns bool

Return whether given instance or name is in the filter stack.

Prototype changed3.0.0callable|string $filter
Method added1.29.0$filter

CarbonPeriod::getFilters

no arguments
returns array

Get filters stack.

Method added1.29.0no arguments

CarbonPeriod::setFilters

array $filters
returns CarbonPeriod

Set filters stack.

Method added1.29.0array $filters

CarbonPeriod::resetFilters

no arguments
returns CarbonPeriod

Reset filters stack.

Method added1.29.0no arguments

CarbonPeriod::setRecurrences

int|float|null $recurrences
returns CarbonPeriod

Add a recurrences filter (set maximum number of recurrences).

Prototype changed3.0.0int|float|null $recurrences
Method added1.29.0$recurrences

CarbonPeriod::setStartDate

mixed $date, ?bool $inclusive = null
returns CarbonPeriod

Change the period start date.

Prototype changed3.0.0mixed $date, ?bool $inclusive = null
Method added1.29.0$date, $inclusive = null

CarbonPeriod::setEndDate

mixed $date, ?bool $inclusive = null
returns CarbonPeriod

Change the period end date.

Prototype changed3.0.0mixed $date, ?bool $inclusive = null
Method added1.29.0$date, $inclusive = null

CarbonPeriod::valid

no arguments
returns bool

Check if the current position is valid.

Method added1.29.0no arguments

CarbonPeriod::key

no arguments
returns int

Return the current key.

Method added1.29.0no arguments

CarbonPeriod::current

no arguments
returns CarbonInterface

Return the current date.

Method added1.29.0no arguments

CarbonPeriod::next

no arguments

Move forward to the next date.

Method added1.29.0no arguments

CarbonPeriod::rewind

no arguments

Rewind to the start date.

Iterating over a date in the UTC timezone avoids bug during backward DST change.

Method added1.29.0no arguments

CarbonPeriod::skip

int $count = 1
returns bool

Skip iterations and returns iteration state (false if ended, true if still valid).

Prototype changed3.0.0int $count = 1
Method added1.30.0$count = 1

CarbonPeriod::toIso8601String

no arguments
returns string

Format the date period as ISO 8601.

Method added1.29.0no arguments

CarbonPeriod::toString

no arguments
returns string

Convert the date period into a string.

Method added1.29.0no arguments

CarbonPeriod::spec

no arguments
returns string

Format the date period as ISO 8601.

Method added1.29.0no arguments

CarbonPeriod::cast

string $className
returns object

Cast the current instance into the given class.

Method added2.23.0string $className

CarbonPeriod::toDatePeriod

no arguments
returns DatePeriod

Return native DatePeriod PHP object matching the current instance.

Examples:

\Carbon\Doc\Generate\var_dump(CarbonPeriod::create('2021-01-05', '2021-02-15')->toDatePeriod());

Method added2.23.0no arguments

CarbonPeriod::isUnfilteredAndEndLess

no arguments
returns bool

Return `true` if the period has no custom filter and is guaranteed to be endless.

Note that we can't check if a period is endless as soon as it has custom filters because filters can emit `CarbonPeriod::END_ITERATION` to stop the iteration in a way we can't predict without actually iterating the period.

Method added2.59.0no arguments

CarbonPeriod::toArray

no arguments
returns array

Convert the date period into an array without changing current iteration state.

Method added1.29.0no arguments

CarbonPeriod::count

no arguments
returns int

Count dates in the date period.

Method added1.29.0no arguments

CarbonPeriod::first

no arguments
returns CarbonInterface

Return the first date in the date period.

Method added1.29.0no arguments

CarbonPeriod::last

no arguments
returns CarbonInterface

Return the last date in the date period.

Method added1.29.0no arguments

CarbonPeriod::__toString

no arguments
returns string

Convert the date period into a string.

Method added1.29.0no arguments

CarbonPeriod::setTimezone

DateTimeZone|string|int $timezone
returns CarbonPeriod

Set the instance's timezone from a string or object and apply it to start/end.

Prototype changed3.0.0DateTimeZone|string|int $timezone
Method added2.52.0$timezone

CarbonPeriod::shiftTimezone

DateTimeZone|string|int $timezone
returns CarbonPeriod

Set the instance's timezone from a string or object and add/subtract the offset difference to start/end.

Prototype changed3.0.0DateTimeZone|string|int $timezone
Method added2.3.0$timezone

CarbonPeriod::calculateEnd

?string $rounding = null
returns CarbonInterface

Returns the end is set, else calculated from start and recurrences.

Prototype changed2.23.0?string $rounding = null
Method added2.20.0no arguments

CarbonPeriod::overlaps

mixed $rangeOrRangeStart, mixed $rangeEnd = null
returns bool

Returns true if the current period overlaps the given one (if 1 parameter passed) or the period between 2 dates (if 2 parameters passed).

Prototype changed3.0.0mixed $rangeOrRangeStart, mixed $rangeEnd = null
Method added2.20.0$rangeOrRangeStart, $rangeEnd = null

CarbonPeriod::forEach

callable $callback

Execute a given function on each date of the period.

Examples:

Carbon::create('2020-11-29')->daysUntil('2020-12-24')->forEach(function (Carbon $date) {
  echo $date->diffInDays('2020-12-25')." days before Christmas!\n";
});

Method added2.22.0callable $callback

CarbonPeriod::map

callable $callback
returns Generator

Execute a given function on each date of the period and yield the result of this function.

Examples:

$period = Carbon::create('2020-11-29')->daysUntil('2020-12-24');
echo implode("\n", iterator_to_array($period->map(function (Carbon $date) {
  return $date->diffInDays('2020-12-25').' days before Christmas!';
})));

Method added2.22.0callable $callback

CarbonPeriod::eq

mixed $period
returns bool

Determines if the instance is equal to another. Warning: if options differ, instances will never be equal.

Prototype changed3.0.0mixed $period
Method added2.22.0$period

CarbonPeriod::equalTo

mixed $period
returns bool

Determines if the instance is equal to another. Warning: if options differ, instances will never be equal.

Prototype changed3.0.0mixed $period
Method added2.22.0$period

CarbonPeriod::ne

mixed $period
returns bool

Determines if the instance is not equal to another. Warning: if options differ, instances will never be equal.

Prototype changed3.0.0mixed $period
Method added2.22.0$period

CarbonPeriod::notEqualTo

mixed $period
returns bool

Determines if the instance is not equal to another. Warning: if options differ, instances will never be equal.

Prototype changed3.0.0mixed $period
Method added2.22.0$period

CarbonPeriod::startsBefore

mixed $date = null
returns bool

Determines if the start date is before another given date. (Rather start/end are included by options is ignored.)

Prototype changed3.0.0mixed $date = null
Method added2.23.0$date = null

CarbonPeriod::startsBeforeOrAt

mixed $date = null
returns bool

Determines if the start date is before or the same as a given date. (Rather start/end are included by options is ignored.)

Prototype changed3.0.0mixed $date = null
Method added2.23.0$date = null

CarbonPeriod::startsAfter

mixed $date = null
returns bool

Determines if the start date is after another given date. (Rather start/end are included by options is ignored.)

Prototype changed3.0.0mixed $date = null
Method added2.23.0$date = null

CarbonPeriod::startsAfterOrAt

mixed $date = null
returns bool

Determines if the start date is after or the same as a given date. (Rather start/end are included by options is ignored.)

Prototype changed3.0.0mixed $date = null
Method added2.23.0$date = null

CarbonPeriod::startsAt

mixed $date = null
returns bool

Determines if the start date is the same as a given date. (Rather start/end are included by options is ignored.)

Prototype changed3.0.0mixed $date = null
Method added2.23.0$date = null

CarbonPeriod::endsBefore

mixed $date = null
returns bool

Determines if the end date is before another given date. (Rather start/end are included by options is ignored.)

Prototype changed3.0.0mixed $date = null
Method added2.23.0$date = null

CarbonPeriod::endsBeforeOrAt

mixed $date = null
returns bool

Determines if the end date is before or the same as a given date. (Rather start/end are included by options is ignored.)

Prototype changed3.0.0mixed $date = null
Method added2.23.0$date = null

CarbonPeriod::endsAfter

mixed $date = null
returns bool

Determines if the end date is after another given date. (Rather start/end are included by options is ignored.)

Prototype changed3.0.0mixed $date = null
Method added2.23.0$date = null

CarbonPeriod::endsAfterOrAt

mixed $date = null
returns bool

Determines if the end date is after or the same as a given date. (Rather start/end are included by options is ignored.)

Prototype changed3.0.0mixed $date = null
Method added2.23.0$date = null

CarbonPeriod::endsAt

mixed $date = null
returns bool

Determines if the end date is the same as a given date. (Rather start/end are included by options is ignored.)

Prototype changed3.0.0mixed $date = null
Method added2.23.0$date = null

CarbonPeriod::isStarted

no arguments
returns bool

Return true if start date is now or later. (Rather start/end are included by options is ignored.)

Method added2.23.0no arguments

CarbonPeriod::isEnded

no arguments
returns bool

Return true if end date is now or later. (Rather start/end are included by options is ignored.)

Method added2.23.0no arguments

CarbonPeriod::isInProgress

no arguments
returns bool

Return true if now is between start date (included) and end date (excluded). (Rather start/end are included by options is ignored.)

Method added2.23.0no arguments

CarbonPeriod::roundUnit

string $unit, DateInterval|string|int|float|null $precision = 1, callable|string $function = 'round'
returns CarbonPeriod

Round the current instance at the given unit with given precision if specified and the given function.

Prototype changed3.0.0string $unit, DateInterval|string|int|float|null $precision = 1, callable|string $function = 'round'
Method added2.23.0$unit, $precision = 1, $function = 'round'

CarbonPeriod::floorUnit

string $unit, DateInterval|string|int|float|null $precision = 1
returns CarbonPeriod

Truncate the current instance at the given unit with given precision if specified.

Prototype changed3.0.0string $unit, DateInterval|string|int|float|null $precision = 1
Method added2.23.0$unit, $precision = 1

CarbonPeriod::ceilUnit

string $unit, DateInterval|string|int|float|null $precision = 1
returns CarbonPeriod

Ceil the current instance at the given unit with given precision if specified.

Prototype changed3.0.0string $unit, DateInterval|string|int|float|null $precision = 1
Method added2.23.0$unit, $precision = 1

CarbonPeriod::round

DateInterval|string|int|float|null $precision = null, callable|string $function = 'round'
returns CarbonPeriod

Round the current instance second with given precision if specified (else period interval is used).

Prototype changed3.0.0DateInterval|string|int|float|null $precision = null, callable|string $function = 'round'
Method added2.23.0$precision = null, $function = 'round'

CarbonPeriod::floor

DateInterval|string|int|float|null $precision = null
returns CarbonPeriod

Round the current instance second with given precision if specified (else period interval is used).

Prototype changed3.0.0DateInterval|string|int|float|null $precision = null
Method added2.23.0$precision = null

CarbonPeriod::ceil

DateInterval|string|int|float|null $precision = null
returns CarbonPeriod

Ceil the current instance second with given precision if specified (else period interval is used).

Prototype changed3.0.0DateInterval|string|int|float|null $precision = null
Method added2.23.0$precision = null

CarbonPeriod::jsonSerialize

no arguments
returns array

Specify data which should be serialized to JSON.

Method added2.23.0no arguments

CarbonPeriod::contains

mixed $date = null
returns bool

Return true if the given date is between start and end.

Prototype changed3.0.0mixed $date = null
Method added2.23.0$date = null

CarbonPeriod::follows

mixed $period, mixed $arguments
returns bool

Return true if the current period follows a given other period (with no overlap). For instance, [2019-08-01 -> 2019-08-12] follows [2019-07-29 -> 2019-07-31] Note than in this example, follows() would be false if 2019-08-01 or 2019-07-31 was excluded by options.

Prototype changed3.0.0mixed $period, mixed $arguments
Method added2.23.0$period, $arguments

CarbonPeriod::isFollowedBy

mixed $period, mixed $arguments
returns bool

Return true if the given other period follows the current one (with no overlap). For instance, [2019-07-29 -> 2019-07-31] is followed by [2019-08-01 -> 2019-08-12] Note than in this example, isFollowedBy() would be false if 2019-08-01 or 2019-07-31 was excluded by options.

Prototype changed3.0.0mixed $period, mixed $arguments
Method added2.23.0$period, $arguments

CarbonPeriod::isConsecutiveWith

mixed $period, mixed $arguments
returns bool

Return true if the given period either follows or is followed by the current one.

Prototype changed3.0.0mixed $period, mixed $arguments
Method added2.23.0$period, $arguments

CarbonPeriod::__debugInfo

no arguments
returns array

Show truthy properties on \Carbon\Doc\Generate\var_dump().

Method added2.17.0no arguments

CarbonPeriod::createFromISO8601String

string $specification, int $options = 0
returns CarbonPeriod

Method added3.0.0string $specification, int $options = 0

CarbonPeriod::__serialize

no arguments
returns array

Returns the values to dump on serialize() called on.

Only used by PHP >= 7.4.

Method added3.0.0no arguments

CarbonPeriod::__unserialize

array $data

Set locale if specified on unserialize() called.

Only used by PHP >= 7.4.

Method added3.0.0array $data

CarbonPeriod::__wakeup

no arguments

Set locale if specified on unserialize() called.

Only used by PHP < 7.4.

Method added3.0.0no arguments

CarbonPeriod::__set_state

array $array
returns CarbonPeriod

The __set_state handler.

Method added3.0.0array $array

CarbonPeriod::getClock

no arguments
returns WrapperClock

Method added3.0.0no arguments

CarbonPeriod::baseMixin

object|string $mixin

Mix another object into the class.

Examples:

Carbon::mixin(new class {
  public function addMoon() {
    return function () {
      return $this->addDays(30);
    };
  }
  public function subMoon() {
    return function () {
      return $this->subDays(30);
    };
  }
});
$fullMoon = Carbon::create('2018-12-22');
$nextFullMoon = $fullMoon->addMoon();
$blackMoon = Carbon::create('2019-01-06');
$previousBlackMoon = $blackMoon->subMoon();
echo "$nextFullMoon\n";
echo "$previousBlackMoon\n";

Prototype changed3.0.0object|string $mixin
Method added2.23.0$mixin

CarbonPeriod::settings

array $settings
returns CarbonPeriod

Set specific options. - 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

Method added2.0.0array $settings

CarbonPeriod::getSettings

no arguments
returns array

Returns current local settings.

Method added2.3.0no arguments

CarbonPeriod::baseDebugInfo

no arguments
returns array

Show truthy properties on \Carbon\Doc\Generate\var_dump().

Method added3.0.0no arguments

CarbonPeriod::useStrictMode

bool $strictModeEnabled = true

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method.

Prototype changed3.0.0bool $strictModeEnabled = true
Method added2.0.0$strictModeEnabled = true

CarbonPeriod::isStrictModeEnabled

no arguments
returns bool

Returns true if the strict mode is globally in use, false else. (It can be overridden in specific instances.)

Method added2.0.0no arguments

CarbonPeriod::useMonthsOverflow

bool $monthsOverflow = true

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method. Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).

Prototype changed3.0.0bool $monthsOverflow = true
Method added2.0.0$monthsOverflow = true

CarbonPeriod::resetMonthsOverflow

no arguments

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method. Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).

Method added2.0.0no arguments

CarbonPeriod::shouldOverflowMonths

no arguments
returns bool

Get the month overflow global behavior (can be overridden in specific instances).

Method added2.0.0no arguments

CarbonPeriod::useYearsOverflow

bool $yearsOverflow = true

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method. Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).

Prototype changed3.0.0bool $yearsOverflow = true
Method added2.0.0$yearsOverflow = true

CarbonPeriod::resetYearsOverflow

no arguments

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method. Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants are available for quarters, years, decade, centuries, millennia (singular and plural forms).

Method added2.0.0no arguments

CarbonPeriod::shouldOverflowYears

no arguments
returns bool

Get the month overflow global behavior (can be overridden in specific instances).

Method added2.0.0no arguments

CarbonPeriod::hasLocalTranslator

no arguments
returns bool

Return true if the current instance has its own translator.

Method added2.29.0no arguments

CarbonPeriod::getLocalTranslator

no arguments
returns Symfony\Contracts\Translation\TranslatorInterface

Get the translator of the current instance or the default if none set.

Method added2.0.0no arguments

CarbonPeriod::setLocalTranslator

Symfony\Contracts\Translation\TranslatorInterface $translator
returns CarbonPeriod

Set the translator for the current instance.

Prototype changed3.0.0Symfony\Contracts\Translation\TranslatorInterface $translator
Method added2.0.0Symfony\Component\Translation\TranslatorInterface $translator

CarbonPeriod::getTranslationMessageWith

$translator, string $key, ?string $locale = null, ?string $default = null
returns string|Closure|null

Returns raw translation message for a given key.

Method added2.8.0$translator, string $key, ?string $locale = null, ?string $default = null

CarbonPeriod::getTranslationMessage

string $key, ?string $locale = null, ?string $default = null, $translator = null
returns string

Returns raw translation message for a given key.

Method added2.8.0string $key, ?string $locale = null, ?string $default = null, $translator = null

CarbonPeriod::translateWith

Symfony\Contracts\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null
returns string

Translate using translation string or callback available.

Prototype changed3.0.0Symfony\Contracts\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null
Method added2.8.0Symfony\Component\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null

CarbonPeriod::translate

string $key, array $parameters = [], string|int|float|null $number = null, ?Symfony\Contracts\Translation\TranslatorInterface $translator = null, bool $altNumbers = false
returns string

Translate using translation string or callback available.

Prototype changed3.0.0string $key, array $parameters = [], string|int|float|null $number = null, ?Symfony\Contracts\Translation\TranslatorInterface $translator = null, bool $altNumbers = false
Prototype changed2.23.0string $key, array $parameters = [], $number = null, ?Symfony\Component\Translation\TranslatorInterface $translator = null, bool $altNumbers = false
Method added2.8.0string $key, array $parameters = [], $number = null, ?Symfony\Component\Translation\TranslatorInterface $translator = null

CarbonPeriod::translateNumber

int $number
returns string

Returns the alternative number for a given integer if available in the current locale.

Method added2.23.0int $number

CarbonPeriod::translateTimeString

string $timeString, ?string $from = null, ?string $to = null, int $mode = 31
returns string

Translate a time string from a locale to an other.

Prototype changed3.0.0string $timeString, ?string $from = null, ?string $to = null, int $mode = 31
Prototype changed2.35.0$timeString, $from = null, $to = null, $mode = 31
Method added2.16.0$timeString, $from = null, $to = null, $mode = 15

CarbonPeriod::translateTimeStringTo

string $timeString, ?string $to = null
returns string

Translate a time string from the current locale (`$date->locale()`) to an other.

Prototype changed3.0.0string $timeString, ?string $to = null
Method added2.16.0$timeString, $to = null

CarbonPeriod::locale

?string $locale = null, string $fallbackLocales
returns CarbonPeriod|string

Get/set the locale for the current instance.

Prototype changed3.0.0?string $locale = null, string $fallbackLocales
Prototype changed2.16.0?string $locale = null, $fallbackLocales
Method added2.0.0?string $locale = null

CarbonPeriod::getLocale

no arguments
returns string

Get the current translator locale.

Method added2.0.0no arguments

CarbonPeriod::setLocale

string $locale

Set the current translator locale and indicate if the source locale file exists. Pass 'auto' as locale to use the closest language to the current LC_TIME locale.

Prototype changed3.0.0string $locale
Method added2.0.0$locale

CarbonPeriod::setFallbackLocale

string $locale

Set the fallback locale.

Prototype changed3.0.0string $locale
Method added2.16.0$locale

CarbonPeriod::getFallbackLocale

no arguments
returns string

Get the fallback locale.

Method added2.16.0no arguments

CarbonPeriod::executeWithLocale

string $locale, callable $func
returns mixed

Set the current locale to the given, execute the passed function, reset the locale to previous one, then return the result of the closure (or null if the closure was void).

Prototype changed3.0.0string $locale, callable $func
Method added2.0.0$locale, $func

CarbonPeriod::localeHasShortUnits

string $locale
returns bool

Returns true if the given locale is internally supported and has short-units support. Support is considered enabled if either year, day or hour has a short variant translated.

Prototype changed3.0.0string $locale
Method added2.0.0$locale

CarbonPeriod::localeHasDiffSyntax

string $locale
returns bool

Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after). Support is considered enabled if the 4 sentences are translated in the given locale.

Prototype changed3.0.0string $locale
Method added2.0.0$locale

CarbonPeriod::localeHasDiffOneDayWords

string $locale
returns bool

Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow). Support is considered enabled if the 3 words are translated in the given locale.

Prototype changed3.0.0string $locale
Method added2.0.0$locale

CarbonPeriod::localeHasDiffTwoDayWords

string $locale
returns bool

Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow). Support is considered enabled if the 2 words are translated in the given locale.

Prototype changed3.0.0string $locale
Method added2.0.0$locale

CarbonPeriod::localeHasPeriodSyntax

$locale
returns bool

Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X). Support is considered enabled if the 4 sentences are translated in the given locale.

Method added2.0.0$locale

CarbonPeriod::getAvailableLocales

no arguments
returns array

Returns the list of internally available locales and already loaded custom locales. (It will ignore custom translator dynamic loading.)

Method added2.0.0no arguments

CarbonPeriod::getAvailableLocalesInfo

no arguments
returns Language[]

Returns list of Language object for each available locale. This object allow you to get the ISO name, native name, region and variant of the locale.

Method added2.10.1no arguments

CarbonPeriod::setHumanDiffOptions

int $humanDiffOptions

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method.

Prototype changed3.0.0int $humanDiffOptions
Method added2.0.0$humanDiffOptions

CarbonPeriod::enableHumanDiffOption

int $humanDiffOption

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method.

Prototype changed3.0.0int $humanDiffOption
Method added2.0.0$humanDiffOption

CarbonPeriod::disableHumanDiffOption

int $humanDiffOption

To avoid conflict between different third-party libraries, static setters should not be used.
You should rather use the ->settings() method.

Prototype changed3.0.0int $humanDiffOption
Method added2.0.0$humanDiffOption

CarbonPeriod::getHumanDiffOptions

no arguments
returns int

Return default humanDiff() options (merged flags as integer).

Method added2.0.0no arguments

CarbonPeriod::setTranslator

Symfony\Contracts\Translation\TranslatorInterface $translator

Set the default translator instance to use.

Prototype changed3.0.0Symfony\Contracts\Translation\TranslatorInterface $translator
Method added2.0.0Symfony\Component\Translation\TranslatorInterface $translator

CarbonPeriod::getTranslator

no arguments
returns Symfony\Contracts\Translation\TranslatorInterface

Initialize the default translator instance if necessary.

Method added2.0.0no arguments

CarbonPeriod::resetToStringFormat

no arguments

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

Method added2.63.0no arguments

CarbonPeriod::setToStringFormat

Closure|string|null $format

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.

Prototype changed3.0.0Closure|string|null $format
Method added2.63.0$format

CarbonTimeZone::__construct

string|int|float $timezone

Create a new Carbon instance.

Please see the testing aids section (specifically static::setTestNow()) for more on the possibility of this constructor returning a test instance.

Prototype changed3.0.0string|int|float $timezone
Method added2.0.0$timezone = null

CarbonTimeZone::cast

string $className
returns mixed

Cast the current instance into the given class.

Method added2.23.0string $className

CarbonTimeZone::instance

DateTimeZone|string|int|false|null $object, DateTimeZone|string|int|false|null $objectDump = null
returns CarbonTimeZone

Create a CarbonTimeZone from mixed input.

Prototype changed3.0.0DateTimeZone|string|int|false|null $object, DateTimeZone|string|int|false|null $objectDump = null
Prototype changed2.10.0$object = null, $objectDump = null
Method added2.0.0$object = null

CarbonTimeZone::getAbbreviatedName

bool $dst = false
returns string

Returns abbreviated name of the current timezone according to DST setting.

Prototype changed3.0.0bool $dst = false
Method added2.0.0$dst = false

CarbonTimeZone::getAbbr

bool $dst = false
returns string

@alias getAbbreviatedName

Returns abbreviated name of the current timezone according to DST setting.

Prototype changed3.0.0bool $dst = false
Method added2.0.0$dst = false

CarbonTimeZone::toOffsetName

?DateTimeInterface $date = null
returns string

Get the offset as string "sHH:MM" (such as "+00:00" or "-12:30").

Method added2.10.0?DateTimeInterface $date = null

CarbonTimeZone::toOffsetTimeZone

?DateTimeInterface $date = null
returns CarbonTimeZone

Returns a new CarbonTimeZone object using the offset string instead of region string.

Method added2.10.0?DateTimeInterface $date = null

CarbonTimeZone::toRegionName

?DateTimeInterface $date = null, int $isDST = 1
returns string

Returns the first region string (such as "America/Toronto") that matches the current timezone or false if no match is found.

Prototype changed3.0.0?DateTimeInterface $date = null, int $isDST = 1
Method added2.10.0?DateTimeInterface $date = null, $isDst = 1

CarbonTimeZone::toRegionTimeZone

?DateTimeInterface $date = null
returns CarbonTimeZone

Returns a new CarbonTimeZone object using the region string instead of offset string.

Method added2.10.0?DateTimeInterface $date = null

CarbonTimeZone::__toString

no arguments
returns string

Cast to string (get timezone name).

Method added2.10.0no arguments

CarbonTimeZone::getType

no arguments
returns int

Return the type number:

Type 1; A UTC offset, such as -0300 Type 2; A timezone abbreviation, such as GMT Type 3: A timezone identifier, such as Europe/London

Method added2.61.0no arguments

CarbonTimeZone::create

$object = null
returns false|CarbonTimeZone

Create a CarbonTimeZone from mixed input.

Method added2.0.0$object = null

CarbonTimeZone::createFromHourOffset

float $hourOffset
returns false|CarbonTimeZone

Create a CarbonTimeZone from int/float hour offset.

Method added2.33.0float $hourOffset

CarbonTimeZone::createFromMinuteOffset

float $minuteOffset
returns false|CarbonTimeZone

Create a CarbonTimeZone from int/float minute offset.

Method added2.33.0float $minuteOffset

CarbonTimeZone::getOffsetNameFromMinuteOffset

float $minutes
returns string

Convert a total minutes offset into a standardized timezone offset string.

Method added2.33.0float $minutes

CarbonTimeZone::getName

Native PHP method

See PHP documentation for DateTimeZone::getName

CarbonTimeZone::getOffset

Native PHP method

See PHP documentation for DateTimeZone::getOffset

CarbonTimeZone::getTransitions

Native PHP method

See PHP documentation for DateTimeZone::getTransitions

CarbonTimeZone::getLocation

Native PHP method

See PHP documentation for DateTimeZone::getLocation

CarbonTimeZone::listAbbreviations

Native PHP method

See PHP documentation for DateTimeZone::listAbbreviations

CarbonTimeZone::listIdentifiers

Native PHP method

See PHP documentation for DateTimeZone::listIdentifiers

CarbonTimeZone::__serialize

Native PHP method
returns array

See PHP documentation for DateTimeZone::__serialize

CarbonTimeZone::__unserialize

Native PHP method

See PHP documentation for DateTimeZone::__unserialize

CarbonTimeZone::__wakeup

Native PHP method

See PHP documentation for DateTimeZone::__wakeup

CarbonTimeZone::__set_state

Native PHP method
returns CarbonTimeZone

See PHP documentation for DateTimeZone::__set_state

CarbonTimeZone::getClock

no arguments
returns WrapperClock

Method added3.0.0no arguments

Translator::trans

?string $id, array $parameters = [], ?string $domain = null, ?string $locale = null
returns string

Prototype changed2.55.0?string $id, array $parameters = [], ?string $domain = null, ?string $locale = null
Method added1.25.0$id, array $parameters = [], $domain = null, $locale = null

Translator::getFromCatalogue

Symfony\Component\Translation\MessageCatalogueInterface $catalogue, string $id, string $domain = 'messages'
returns mixed

@param mixed $translator

Method added2.55.0Symfony\Component\Translation\MessageCatalogueInterface $catalogue, string $id, string $domain = 'messages'

Translator::get

?string $locale = null
returns Translator

Return a singleton instance of Translator.

Prototype changed3.0.0?string $locale = null
Method added1.25.0$locale = null

Translator::__construct

$locale, ?Symfony\Component\Translation\Formatter\MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false

Create a new Carbon instance.

Please see the testing aids section (specifically static::setTestNow()) for more on the possibility of this constructor returning a test instance.

Prototype changed1.37.1$locale, ?Symfony\Component\Translation\Formatter\MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false
Method added1.25.0$locale, Symfony\Component\Translation\Formatter\MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false

Translator::getDirectories

no arguments
returns array

Returns the list of directories translation files are searched in.

Method added2.0.0no arguments

Translator::setDirectories

array $directories
returns Translator

Set list of directories translation files are searched in.

Method added2.0.0array $directories

Translator::addDirectory

string $directory
returns Translator

Add a directory to the list translation files are searched in.

Method added2.0.0string $directory

Translator::removeDirectory

string $directory
returns Translator

Remove a directory from the list translation files are searched in.

Method added2.0.0string $directory

Translator::resetMessages

?string $locale = null
returns bool

Reset messages of a locale (all locale if no locale passed). Remove custom messages and reload initial messages from matching file in Lang directory.

Prototype changed3.0.0?string $locale = null
Method added1.25.0$locale = null

Translator::getLocalesFiles

string $prefix = ''
returns array

Returns the list of files matching a given locale prefix (or all if empty).

Prototype changed3.0.0string $prefix = ''
Method added2.0.0$prefix = ''

Translator::getAvailableLocales

string $prefix = ''
returns array

Returns the list of internally available locales and already loaded custom locales. (It will ignore custom translator dynamic loading.)

Prototype changed3.0.0string $prefix = ''
Method added2.0.0$prefix = ''

Translator::setMessages

string $locale, array $messages
returns Translator

Set messages of a locale and take file first if present.

Prototype changed3.0.0string $locale, array $messages
Method added1.25.0$locale, $messages

Translator::setTranslations

array $messages
returns Translator

Set messages of the current locale and take file first if present.

Prototype changed3.0.0array $messages
Method added2.9.0$messages

Translator::getMessages

?string $locale = null
returns array

Get messages of a locale, if none given, return all the languages.

Prototype changed3.0.0?string $locale = null
Method added1.25.0$locale = null

Translator::setLocale

$locale

Set the current translator locale and indicate if the source locale file exists

Method added1.25.0$locale

Translator::__debugInfo

no arguments
returns array

Show locale on \Carbon\Doc\Generate\var_dump().

Method added2.17.0no arguments

Translator::__serialize

no arguments
returns array

Returns the values to dump on serialize() called on.

Only used by PHP >= 7.4.

Method added3.3.1no arguments

Translator::__unserialize

array $data

Set locale if specified on unserialize() called.

Only used by PHP >= 7.4.

Method added3.3.1array $data

Translator::setConfigCacheFactory

Method from Symfony interhited class

See Symfony\Component\Translation\Translator::setConfigCacheFactory

Translator::addLoader

Method from Symfony interhited class

See Symfony\Component\Translation\Translator::addLoader

Translator::addResource

Method from Symfony interhited class

See Symfony\Component\Translation\Translator::addResource

Translator::getLocale

Method from Symfony interhited class
returns string

See Symfony\Component\Translation\Translator::getLocale

Translator::setFallbackLocales

Method from Symfony interhited class

See Symfony\Component\Translation\Translator::setFallbackLocales

Translator::getFallbackLocales

Method from Symfony interhited class
returns array

See Symfony\Component\Translation\Translator::getFallbackLocales

Translator::getCatalogue

Method from Symfony interhited class
returns Symfony\Component\Translation\MessageCatalogueInterface

See Symfony\Component\Translation\Translator::getCatalogue

Translator::getCatalogues

Method from Symfony interhited class
returns array

See Symfony\Component\Translation\Translator::getCatalogues

Language::__construct

string $id

Create a new Carbon instance.

Please see the testing aids section (specifically static::setTestNow()) for more on the possibility of this constructor returning a test instance.

Method added2.10.1string $id

Language::all

no arguments
returns array

Get the list of the known languages.

Method added2.10.1no arguments

Language::regions

no arguments
returns array

Get the list of the known regions.

⚠ ISO 3166-2 short name provided with no warranty, should not be used for any purpose to show official state names.

Method added2.10.1no arguments

Language::getNames

no arguments
returns array

Get both isoName and nativeName as an array.

Method added2.10.1no arguments

Language::getId

no arguments
returns string

Returns the original locale ID.

Method added2.10.1no arguments

Language::getCode

no arguments
returns string

Returns the code of the locale "en"/"fr".

Method added2.10.1no arguments

Language::getVariant

no arguments
returns string

Returns the variant code such as cyrl/latn.

Method added2.10.1no arguments

Language::getVariantName

no arguments
returns string

Returns the variant such as Cyrillic/Latin.

Method added2.10.1no arguments

Language::getRegion

no arguments
returns string

Returns the region part of the locale.

Method added2.10.1no arguments

Language::getRegionName

no arguments
returns string

Returns the region name for the current language.

⚠ ISO 3166-2 short name provided with no warranty, should not be used for any purpose to show official state names.

Method added2.10.1no arguments

Language::getFullIsoName

no arguments
returns string

Returns the long ISO language name.

Method added2.10.1no arguments

Language::setIsoName

string $isoName
returns Language

Set the ISO language name.

Method added2.10.1string $isoName

Language::getFullNativeName

no arguments
returns string

Return the full name of the language in this language.

Method added2.10.1no arguments

Language::setNativeName

string $nativeName
returns Language

Set the name of the language in this language.

Method added2.10.1string $nativeName

Language::getIsoName

no arguments
returns string

Returns the short ISO language name.

Method added2.10.1no arguments

Language::getNativeName

no arguments
returns string

Get the short name of the language in this language.

Method added2.10.1no arguments

Language::getIsoDescription

no arguments
returns string

Get a string with short ISO name, region in parentheses if applicable, variant in parentheses if applicable.

Method added2.10.1no arguments

Language::getNativeDescription

no arguments
returns string

Get a string with short native name, region in parentheses if applicable, variant in parentheses if applicable.

Method added2.10.1no arguments

Language::getFullIsoDescription

no arguments
returns string

Get a string with long ISO name, region in parentheses if applicable, variant in parentheses if applicable.

Method added2.10.1no arguments

Language::getFullNativeDescription

no arguments
returns string

Get a string with long native name, region in parentheses if applicable, variant in parentheses if applicable.

Method added2.10.1no arguments

Language::__toString

no arguments
returns string

Returns the original locale ID.

Method added2.10.1no arguments

Language::jsonSerialize

no arguments
returns string

Get a string with short ISO name, region in parentheses if applicable, variant in parentheses if applicable.

Method added2.10.1no arguments

Carbon::isUtc

no arguments
returns bool

Check if the current instance has UTC timezone. (Both isUtc and isUTC cases are valid.)

Method added2.0.0no arguments

Carbon::isLocal

no arguments
returns bool

Check if the current instance has non-UTC timezone.

Method added2.0.0no arguments

Carbon::isValid

no arguments
returns bool

Check if the current instance is a valid date.

Method added2.0.0no arguments

Carbon::isDST

no arguments
returns bool

Check if the current instance is in a daylight saving time.

Method added2.0.0no arguments

Carbon::isSunday

no arguments
returns bool

Checks if the instance day is sunday.

Method added1.20.0no arguments

Carbon::isMonday

no arguments
returns bool

Checks if the instance day is monday.

Method added1.20.0no arguments

Carbon::isTuesday

no arguments
returns bool

Checks if the instance day is tuesday.

Method added1.20.0no arguments

Carbon::isWednesday

no arguments
returns bool

Checks if the instance day is wednesday.

Method added1.20.0no arguments

Carbon::isThursday

no arguments
returns bool

Checks if the instance day is thursday.

Method added1.20.0no arguments

Carbon::isFriday

no arguments
returns bool

Checks if the instance day is friday.

Method added1.20.0no arguments

Carbon::isSaturday

no arguments
returns bool

Checks if the instance day is saturday.

Method added1.20.0no arguments

Carbon::isSameYear

DateTimeInterface|string $date
returns bool

Checks if the given date is in the same year as the instance. If null passed, compare to now (with the same timezone).

Prototype changed3.2.0DateTimeInterface|string $date
Prototype changed2.34.2Carbon|DateTimeInterface|string|null $date = null
Prototype changed2.24.0\Carbon\Carbon|\DateTimeInterface|string|null $date = null
Prototype changed2.0.0\DateTimeInterface $date = null
Prototype changed1.23.0$date = null
Method added1.22.0Carbon\Carbon $date = null

Carbon::isCurrentYear

no arguments
returns bool

Checks if the instance is in the same year as the current moment.

Method added1.22.0no arguments

Carbon::isNextYear

no arguments
returns bool

Checks if the instance is in the same year as the current moment next year.

Method added1.22.0no arguments

Carbon::isLastYear

no arguments
returns bool

Checks if the instance is in the same year as the current moment last year.

Method added1.22.0no arguments

Carbon::isCurrentMonth

no arguments
returns bool

Checks if the instance is in the same month as the current moment.

Prototype changed2.0.0no arguments
Prototype changed1.29.2$ofSameYear = null
Method added1.22.0no arguments

Carbon::isNextMonth

no arguments
returns bool

Checks if the instance is in the same month as the current moment next month.

Method added1.22.0no arguments

Carbon::isLastMonth

no arguments
returns bool

Checks if the instance is in the same month as the current moment last month.

Method added1.22.0no arguments

Carbon::isSameWeek

DateTimeInterface|string $date
returns bool

Checks if the given date is in the same week as the instance. If null passed, compare to now (with the same timezone).

Prototype changed3.2.0DateTimeInterface|string $date
Prototype changed2.34.2Carbon|DateTimeInterface|string|null $date = null
Prototype changed2.24.0\Carbon\Carbon|\DateTimeInterface|string|null $date = null
Method added2.0.0\DateTimeInterface $date = null

Carbon::isCurrentWeek

no arguments
returns bool

Checks if the instance is in the same week as the current moment.

Method added2.0.0no arguments

Carbon::isNextWeek

no arguments
returns bool

Checks if the instance is in the same week as the current moment next week.

Method added1.22.0no arguments

Carbon::isLastWeek

no arguments
returns bool

Checks if the instance is in the same week as the current moment last week.

Method added1.22.0no arguments

Carbon::isSameDay

DateTimeInterface|string $date
returns bool

Checks if the given date is in the same day as the instance. If null passed, compare to now (with the same timezone).

Prototype changed3.2.0DateTimeInterface|string $date
Prototype changed2.34.2Carbon|DateTimeInterface|string|null $date = null
Prototype changed2.24.0\Carbon\Carbon|\DateTimeInterface|string|null $date = null
Prototype changed2.0.0\DateTimeInterface $date = null
Prototype changed1.27.0$date = null
Prototype changed1.23.0$date
Method added1.11.0Carbon\Carbon $date

Carbon::isCurrentDay

no arguments
returns bool

Checks if the instance is in the same day as the current moment.

Method added1.27.0no arguments

Carbon::isNextDay

no arguments
returns bool

Checks if the instance is in the same day as the current moment next day.

Method added2.0.0no arguments

Carbon::isLastDay

no arguments
returns bool

Checks if the instance is in the same day as the current moment last day.

Method added2.0.0no arguments

Carbon::isSameHour

DateTimeInterface|string $date
returns bool

Checks if the given date is in the same hour as the instance. If null passed, compare to now (with the same timezone).

Prototype changed3.2.0DateTimeInterface|string $date
Prototype changed2.34.2Carbon|DateTimeInterface|string|null $date = null
Prototype changed2.24.0\Carbon\Carbon|\DateTimeInterface|string|null $date = null
Prototype changed2.0.0\DateTimeInterface $date = null
Method added1.27.0$date = null

Carbon::isCurrentHour

no arguments
returns bool

Checks if the instance is in the same hour as the current moment.

Method added1.27.0no arguments

Carbon::isNextHour

no arguments
returns bool

Checks if the instance is in the same hour as the current moment next hour.

Method added2.0.0no arguments

Carbon::isLastHour

no arguments
returns bool

Checks if the instance is in the same hour as the current moment last hour.

Method added2.0.0no arguments

Carbon::isSameMinute

DateTimeInterface|string $date
returns bool

Checks if the given date is in the same minute as the instance. If null passed, compare to now (with the same timezone).

Prototype changed3.2.0DateTimeInterface|string $date
Prototype changed2.34.2Carbon|DateTimeInterface|string|null $date = null
Prototype changed2.24.0\Carbon\Carbon|\DateTimeInterface|string|null $date = null
Prototype changed2.0.0\DateTimeInterface $date = null
Method added1.27.0$date = null

Carbon::isCurrentMinute

no arguments
returns bool

Checks if the instance is in the same minute as the current moment.

Method added1.27.0no arguments

Carbon::isNextMinute

no arguments
returns bool

Checks if the instance is in the same minute as the current moment next minute.

Method added2.0.0no arguments

Carbon::isLastMinute

no arguments
returns bool

Checks if the instance is in the same minute as the current moment last minute.

Method added2.0.0no arguments

Carbon::isSameSecond

DateTimeInterface|string $date
returns bool

Checks if the given date is in the same second as the instance. If null passed, compare to now (with the same timezone).

Prototype changed3.2.0DateTimeInterface|string $date
Prototype changed2.34.2Carbon|DateTimeInterface|string|null $date = null
Prototype changed2.24.0\Carbon\Carbon|\DateTimeInterface|string|null $date = null
Prototype changed2.0.0\DateTimeInterface $date = null
Method added1.27.0$date = null

Carbon::isCurrentSecond

no arguments
returns bool

Checks if the instance is in the same second as the current moment.

Method added1.27.0no arguments

Carbon::isNextSecond

no arguments
returns bool

Checks if the instance is in the same second as the current moment next second.

Method added2.0.0no arguments

Carbon::isLastSecond

no arguments
returns bool

Checks if the instance is in the same second as the current moment last second.

Method added2.0.0no arguments

Carbon::isSameMilli

DateTimeInterface|string $date
returns bool

Checks if the given date is in the same millisecond as the instance. If null passed, compare to now (with the same timezone).

Prototype changed3.2.0DateTimeInterface|string $date
Method added3.0.0Carbon|DateTimeInterface|string|null $date = null

Carbon::isCurrentMilli

no arguments
returns bool

Checks if the instance is in the same millisecond as the current moment.

Method added3.0.0no arguments

Carbon::isNextMilli

no arguments
returns bool

Checks if the instance is in the same millisecond as the current moment next millisecond.

Method added3.0.0no arguments

Carbon::isLastMilli

no arguments
returns bool

Checks if the instance is in the same millisecond as the current moment last millisecond.

Method added3.0.0no arguments

Carbon::isSameMillisecond

DateTimeInterface|string $date
returns bool

Checks if the given date is in the same millisecond as the instance. If null passed, compare to now (with the same timezone).

Prototype changed3.2.0DateTimeInterface|string $date
Method added3.0.0Carbon|DateTimeInterface|string|null $date = null

Carbon::isCurrentMillisecond

no arguments
returns bool

Checks if the instance is in the same millisecond as the current moment.

Method added3.0.0no arguments

Carbon::isNextMillisecond

no arguments
returns bool

Checks if the instance is in the same millisecond as the current moment next millisecond.

Method added3.0.0no arguments

Carbon::isLastMillisecond

no arguments
returns bool

Checks if the instance is in the same millisecond as the current moment last millisecond.

Method added3.0.0no arguments

Carbon::isSameMicro

DateTimeInterface|string $date
returns bool

Checks if the given date is in the same microsecond as the instance. If null passed, compare to now (with the same timezone).

Prototype changed3.2.0DateTimeInterface|string $date
Prototype changed2.34.2Carbon|DateTimeInterface|string|null $date = null
Prototype changed2.24.0\Carbon\Carbon|\DateTimeInterface|string|null $date = null
Method added2.0.0\DateTimeInterface $date = null

Carbon::isCurrentMicro

no arguments
returns bool

Checks if the instance is in the same microsecond as the current moment.

Method added2.0.0no arguments

Carbon::isNextMicro

no arguments
returns bool

Checks if the instance is in the same microsecond as the current moment next microsecond.

Method added2.0.0no arguments

Carbon::isLastMicro

no arguments
returns bool

Checks if the instance is in the same microsecond as the current moment last microsecond.

Method added2.0.0no arguments

Carbon::isSameMicrosecond

DateTimeInterface|string $date
returns bool

Checks if the given date is in the same microsecond as the instance. If null passed, compare to now (with the same timezone).

Prototype changed3.2.0DateTimeInterface|string $date
Prototype changed2.34.2Carbon|DateTimeInterface|string|null $date = null
Prototype changed2.24.0\Carbon\Carbon|\DateTimeInterface|string|null $date = null
Method added2.0.0\DateTimeInterface $date = null

Carbon::isCurrentMicrosecond

no arguments
returns bool

Checks if the instance is in the same microsecond as the current moment.

Method added2.0.0no arguments

Carbon::isNextMicrosecond

no arguments
returns bool

Checks if the instance is in the same microsecond as the current moment next microsecond.

Method added2.0.0no arguments

Carbon::isLastMicrosecond

no arguments
returns bool

Checks if the instance is in the same microsecond as the current moment last microsecond.

Method added2.0.0no arguments

Carbon::isSameDecade

DateTimeInterface|string $date
returns bool

Checks if the given date is in the same decade as the instance. If null passed, compare to now (with the same timezone).

Prototype changed3.2.0DateTimeInterface|string $date
Prototype changed2.34.2Carbon|DateTimeInterface|string|null $date = null
Prototype changed2.24.0\Carbon\Carbon|\DateTimeInterface|string|null $date = null
Method added2.0.0\DateTimeInterface $date = null

Carbon::isCurrentDecade

no arguments
returns bool

Checks if the instance is in the same decade as the current moment.

Method added2.0.0no arguments

Carbon::isNextDecade

no arguments
returns bool

Checks if the instance is in the same decade as the current moment next decade.

Method added2.0.0no arguments

Carbon::isLastDecade

no arguments
returns bool

Checks if the instance is in the same decade as the current moment last decade.

Method added2.0.0no arguments

Carbon::isSameCentury

DateTimeInterface|string $date
returns bool

Checks if the given date is in the same century as the instance. If null passed, compare to now (with the same timezone).

Prototype changed3.2.0DateTimeInterface|string $date
Prototype changed2.34.2Carbon|DateTimeInterface|string|null $date = null
Prototype changed2.24.0\Carbon\Carbon|\DateTimeInterface|string|null $date = null
Method added2.0.0\DateTimeInterface $date = null

Carbon::isCurrentCentury

no arguments
returns bool

Checks if the instance is in the same century as the current moment.

Method added2.0.0no arguments

Carbon::isNextCentury

no arguments
returns bool

Checks if the instance is in the same century as the current moment next century.

Method added2.0.0no arguments

Carbon::isLastCentury

no arguments
returns bool

Checks if the instance is in the same century as the current moment last century.

Method added2.0.0no arguments

Carbon::isSameMillennium

DateTimeInterface|string $date
returns bool

Checks if the given date is in the same millennium as the instance. If null passed, compare to now (with the same timezone).

Prototype changed3.2.0DateTimeInterface|string $date
Prototype changed2.34.2Carbon|DateTimeInterface|string|null $date = null
Prototype changed2.24.0\Carbon\Carbon|\DateTimeInterface|string|null $date = null
Method added2.0.0\DateTimeInterface $date = null

Carbon::isCurrentMillennium

no arguments
returns bool

Checks if the instance is in the same millennium as the current moment.

Method added2.0.0no arguments

Carbon::isNextMillennium

no arguments
returns bool

Checks if the instance is in the same millennium as the current moment next millennium.

Method added2.0.0no arguments

Carbon::isLastMillennium

no arguments
returns bool

Checks if the instance is in the same millennium as the current moment last millennium.

Method added2.0.0no arguments

Carbon::isCurrentQuarter

no arguments
returns bool

Checks if the instance is in the same quarter as the current moment.

Method added1.26.4no arguments

Carbon::isNextQuarter

no arguments
returns bool

Checks if the instance is in the same quarter as the current moment next quarter.

Method added1.26.4no arguments

Carbon::isLastQuarter

no arguments
returns bool

Checks if the instance is in the same quarter as the current moment last quarter.

Method added1.26.4no arguments

Carbon::years

int $value
returns $this

Set current instance year to the given value.

Method added2.0.0int $value

Carbon::year

int $value
returns $this

Set current instance year to the given value.

Prototype changed2.0.0int $value
Method added1.0.0$value

Carbon::setYears

int $value
returns $this

Set current instance year to the given value.

Method added2.0.0int $value

Carbon::setYear

int $value
returns $this

Set current instance year to the given value.

Method added2.0.0int $value

Carbon::months

Month|int $value
returns $this

Set current instance month to the given value.

Prototype changed3.0.0Month|int $value
Method added2.0.0int $value

Carbon::month

Month|int $value
returns $this

Set current instance month to the given value.

Prototype changed3.0.0Month|int $value
Prototype changed2.0.0int $value
Method added1.0.0$value

Carbon::setMonths

Month|int $value
returns $this

Set current instance month to the given value.

Prototype changed3.0.0Month|int $value
Method added2.0.0int $value

Carbon::setMonth

Month|int $value
returns $this

Set current instance month to the given value.

Prototype changed3.0.0Month|int $value
Method added2.0.0int $value

Carbon::days

int $value
returns $this

Set current instance day to the given value.

Method added2.0.0int $value

Carbon::day

int $value
returns $this

Set current instance day to the given value.

Prototype changed2.0.0int $value
Method added1.0.0$value

Carbon::setDays

int $value
returns $this

Set current instance day to the given value.

Method added2.0.0int $value

Carbon::setDay

int $value
returns $this

Set current instance day to the given value.

Method added2.0.0int $value

Carbon::hours

int $value
returns $this

Set current instance hour to the given value.

Method added2.0.0int $value

Carbon::hour

int $value
returns $this

Set current instance hour to the given value.

Prototype changed2.0.0int $value
Method added1.0.0$value

Carbon::setHours

int $value
returns $this

Set current instance hour to the given value.

Method added2.0.0int $value

Carbon::setHour

int $value
returns $this

Set current instance hour to the given value.

Method added2.0.0int $value

Carbon::minutes

int $value
returns $this

Set current instance minute to the given value.

Method added2.0.0int $value

Carbon::minute

int $value
returns $this

Set current instance minute to the given value.

Prototype changed2.0.0int $value
Method added1.0.0$value

Carbon::setMinutes

int $value
returns $this

Set current instance minute to the given value.

Method added2.0.0int $value

Carbon::setMinute

int $value
returns $this

Set current instance minute to the given value.

Method added2.0.0int $value

Carbon::seconds

int $value
returns $this

Set current instance second to the given value.

Method added2.0.0int $value

Carbon::second

int $value
returns $this

Set current instance second to the given value.

Prototype changed2.0.0int $value
Method added1.0.0$value

Carbon::setSeconds

int $value
returns $this

Set current instance second to the given value.

Method added2.0.0int $value

Carbon::setSecond

int $value
returns $this

Set current instance second to the given value.

Method added2.0.0int $value

Carbon::millis

int $value
returns $this

Set current instance millisecond to the given value.

Method added2.7.0int $value

Carbon::milli

int $value
returns $this

Set current instance millisecond to the given value.

Method added2.7.0int $value

Carbon::setMillis

int $value
returns $this

Set current instance millisecond to the given value.

Method added2.7.0int $value

Carbon::setMilli

int $value
returns $this

Set current instance millisecond to the given value.

Method added2.7.0int $value

Carbon::milliseconds

int $value
returns $this

Set current instance millisecond to the given value.

Method added2.7.0int $value

Carbon::millisecond

int $value
returns $this

Set current instance millisecond to the given value.

Method added2.7.0int $value

Carbon::setMilliseconds

int $value
returns $this

Set current instance millisecond to the given value.

Method added2.7.0int $value

Carbon::setMillisecond

int $value
returns $this

Set current instance millisecond to the given value.

Method added2.7.0int $value

Carbon::micros

int $value
returns $this

Set current instance microsecond to the given value.

Method added2.0.0int $value

Carbon::micro

int $value
returns $this

Set current instance microsecond to the given value.

Method added2.0.0int $value

Carbon::setMicros

int $value
returns $this

Set current instance microsecond to the given value.

Method added2.0.0int $value

Carbon::setMicro

int $value
returns $this

Set current instance microsecond to the given value.

Method added2.0.0int $value

Carbon::microseconds

int $value
returns $this

Set current instance microsecond to the given value.

Method added2.0.0int $value

Carbon::microsecond

int $value
returns $this

Set current instance microsecond to the given value.

Method added2.0.0int $value

Carbon::setMicroseconds

int $value
returns $this

Set current instance microsecond to the given value.

Method added2.0.0int $value

Carbon::setMicrosecond

int $value
returns $this

Set current instance microsecond to the given value.

Method added2.0.0int $value

Carbon::addYears

int|float $value = 1
returns $this

Add years (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::addYear

no arguments
returns $this

Add one year to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::subYears

int|float $value = 1
returns $this

Sub years (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::subYear

no arguments
returns $this

Sub one year to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::addYearsWithOverflow

int|float $value = 1
returns $this

Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.24.0$value

Carbon::addYearWithOverflow

no arguments
returns $this

Add one year to the instance (using date interval) with overflow explicitly allowed.

Prototype changed2.0.0no arguments
Method added1.24.0$value = 1

Carbon::subYearsWithOverflow

int|float $value = 1
returns $this

Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.24.0$value

Carbon::subYearWithOverflow

no arguments
returns $this

Sub one year to the instance (using date interval) with overflow explicitly allowed.

Prototype changed2.0.0no arguments
Method added1.24.0$value = 1

Carbon::addYearsWithoutOverflow

int|float $value = 1
returns $this

Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addYearWithoutOverflow

no arguments
returns $this

Add one year to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subYearsWithoutOverflow

int|float $value = 1
returns $this

Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subYearWithoutOverflow

no arguments
returns $this

Sub one year to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addYearsWithNoOverflow

int|float $value = 1
returns $this

Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addYearWithNoOverflow

no arguments
returns $this

Add one year to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subYearsWithNoOverflow

int|float $value = 1
returns $this

Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subYearWithNoOverflow

no arguments
returns $this

Sub one year to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addYearsNoOverflow

int|float $value = 1
returns $this

Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.24.0$value

Carbon::addYearNoOverflow

no arguments
returns $this

Add one year to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed2.0.0no arguments
Method added1.24.0$value = 1

Carbon::subYearsNoOverflow

int|float $value = 1
returns $this

Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.24.0$value

Carbon::subYearNoOverflow

no arguments
returns $this

Sub one year to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed2.0.0no arguments
Method added1.24.0$value = 1

Carbon::addMonths

int|float $value = 1
returns $this

Add months (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::addMonth

no arguments
returns $this

Add one month to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::subMonths

int|float $value = 1
returns $this

Sub months (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::subMonth

no arguments
returns $this

Sub one month to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::addMonthsWithOverflow

int|float $value = 1
returns $this

Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.22.0$value

Carbon::addMonthWithOverflow

no arguments
returns $this

Add one month to the instance (using date interval) with overflow explicitly allowed.

Prototype changed2.0.0no arguments
Method added1.22.0$value = 1

Carbon::subMonthsWithOverflow

int|float $value = 1
returns $this

Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.22.0$value

Carbon::subMonthWithOverflow

no arguments
returns $this

Sub one month to the instance (using date interval) with overflow explicitly allowed.

Prototype changed2.0.0no arguments
Method added1.22.0$value = 1

Carbon::addMonthsWithoutOverflow

int|float $value = 1
returns $this

Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addMonthWithoutOverflow

no arguments
returns $this

Add one month to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subMonthsWithoutOverflow

int|float $value = 1
returns $this

Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subMonthWithoutOverflow

no arguments
returns $this

Sub one month to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addMonthsWithNoOverflow

int|float $value = 1
returns $this

Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addMonthWithNoOverflow

no arguments
returns $this

Add one month to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subMonthsWithNoOverflow

int|float $value = 1
returns $this

Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subMonthWithNoOverflow

no arguments
returns $this

Sub one month to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addMonthsNoOverflow

int|float $value = 1
returns $this

Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.14.0$value

Carbon::addMonthNoOverflow

no arguments
returns $this

Add one month to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.14.0no arguments

Carbon::subMonthsNoOverflow

int|float $value = 1
returns $this

Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.14.0$value

Carbon::subMonthNoOverflow

no arguments
returns $this

Sub one month to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.14.0no arguments

Carbon::addDays

int|float $value = 1
returns $this

Add days (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::addDay

no arguments
returns $this

Add one day to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::subDays

int|float $value = 1
returns $this

Sub days (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::subDay

no arguments
returns $this

Sub one day to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::addHours

int|float $value = 1
returns $this

Add hours (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::addHour

no arguments
returns $this

Add one hour to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::subHours

int|float $value = 1
returns $this

Sub hours (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::subHour

no arguments
returns $this

Sub one hour to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::addMinutes

int|float $value = 1
returns $this

Add minutes (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::addMinute

no arguments
returns $this

Add one minute to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::subMinutes

int|float $value = 1
returns $this

Sub minutes (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::subMinute

no arguments
returns $this

Sub one minute to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::addSeconds

int|float $value = 1
returns $this

Add seconds (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::addSecond

no arguments
returns $this

Add one second to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::subSeconds

int|float $value = 1
returns $this

Sub seconds (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::subSecond

no arguments
returns $this

Sub one second to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::addMillis

int|float $value = 1
returns $this

Add milliseconds (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Method added2.6.0int $value = 1

Carbon::addMilli

no arguments
returns $this

Add one millisecond to the instance (using date interval).

Method added2.6.0no arguments

Carbon::subMillis

int|float $value = 1
returns $this

Sub milliseconds (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Method added2.6.0int $value = 1

Carbon::subMilli

no arguments
returns $this

Sub one millisecond to the instance (using date interval).

Method added2.6.0no arguments

Carbon::addMilliseconds

int|float $value = 1
returns $this

Add milliseconds (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Method added2.6.0int $value = 1

Carbon::addMillisecond

no arguments
returns $this

Add one millisecond to the instance (using date interval).

Method added2.6.0no arguments

Carbon::subMilliseconds

int|float $value = 1
returns $this

Sub milliseconds (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Method added2.6.0int $value = 1

Carbon::subMillisecond

no arguments
returns $this

Sub one millisecond to the instance (using date interval).

Method added2.6.0no arguments

Carbon::addMicros

int|float $value = 1
returns $this

Add microseconds (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addMicro

no arguments
returns $this

Add one microsecond to the instance (using date interval).

Method added2.0.0no arguments

Carbon::subMicros

int|float $value = 1
returns $this

Sub microseconds (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subMicro

no arguments
returns $this

Sub one microsecond to the instance (using date interval).

Method added2.0.0no arguments

Carbon::addMicroseconds

int|float $value = 1
returns $this

Add microseconds (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addMicrosecond

no arguments
returns $this

Add one microsecond to the instance (using date interval).

Method added2.0.0no arguments

Carbon::subMicroseconds

int|float $value = 1
returns $this

Sub microseconds (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subMicrosecond

no arguments
returns $this

Sub one microsecond to the instance (using date interval).

Method added2.0.0no arguments

Carbon::addMillennia

int|float $value = 1
returns $this

Add millennia (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addMillennium

no arguments
returns $this

Add one millennium to the instance (using date interval).

Method added2.0.0no arguments

Carbon::subMillennia

int|float $value = 1
returns $this

Sub millennia (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subMillennium

no arguments
returns $this

Sub one millennium to the instance (using date interval).

Method added2.0.0no arguments

Carbon::addMillenniaWithOverflow

int|float $value = 1
returns $this

Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addMillenniumWithOverflow

no arguments
returns $this

Add one millennium to the instance (using date interval) with overflow explicitly allowed.

Method added2.0.0no arguments

Carbon::subMillenniaWithOverflow

int|float $value = 1
returns $this

Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subMillenniumWithOverflow

no arguments
returns $this

Sub one millennium to the instance (using date interval) with overflow explicitly allowed.

Method added2.0.0no arguments

Carbon::addMillenniaWithoutOverflow

int|float $value = 1
returns $this

Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addMillenniumWithoutOverflow

no arguments
returns $this

Add one millennium to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subMillenniaWithoutOverflow

int|float $value = 1
returns $this

Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subMillenniumWithoutOverflow

no arguments
returns $this

Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addMillenniaWithNoOverflow

int|float $value = 1
returns $this

Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addMillenniumWithNoOverflow

no arguments
returns $this

Add one millennium to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subMillenniaWithNoOverflow

int|float $value = 1
returns $this

Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subMillenniumWithNoOverflow

no arguments
returns $this

Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addMillenniaNoOverflow

int|float $value = 1
returns $this

Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addMillenniumNoOverflow

no arguments
returns $this

Add one millennium to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subMillenniaNoOverflow

int|float $value = 1
returns $this

Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subMillenniumNoOverflow

no arguments
returns $this

Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addCenturies

int|float $value = 1
returns $this

Add centuries (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.22.0$value

Carbon::addCentury

no arguments
returns $this

Add one century to the instance (using date interval).

Prototype changed2.0.0no arguments
Method added1.22.0$value = 1

Carbon::subCenturies

int|float $value = 1
returns $this

Sub centuries (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.22.0$value

Carbon::subCentury

no arguments
returns $this

Sub one century to the instance (using date interval).

Prototype changed2.0.0no arguments
Method added1.22.0$value = 1

Carbon::addCenturiesWithOverflow

int|float $value = 1
returns $this

Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addCenturyWithOverflow

no arguments
returns $this

Add one century to the instance (using date interval) with overflow explicitly allowed.

Method added2.0.0no arguments

Carbon::subCenturiesWithOverflow

int|float $value = 1
returns $this

Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subCenturyWithOverflow

no arguments
returns $this

Sub one century to the instance (using date interval) with overflow explicitly allowed.

Method added2.0.0no arguments

Carbon::addCenturiesWithoutOverflow

int|float $value = 1
returns $this

Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addCenturyWithoutOverflow

no arguments
returns $this

Add one century to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subCenturiesWithoutOverflow

int|float $value = 1
returns $this

Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subCenturyWithoutOverflow

no arguments
returns $this

Sub one century to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addCenturiesWithNoOverflow

int|float $value = 1
returns $this

Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addCenturyWithNoOverflow

no arguments
returns $this

Add one century to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subCenturiesWithNoOverflow

int|float $value = 1
returns $this

Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subCenturyWithNoOverflow

no arguments
returns $this

Sub one century to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addCenturiesNoOverflow

int|float $value = 1
returns $this

Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addCenturyNoOverflow

no arguments
returns $this

Add one century to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subCenturiesNoOverflow

int|float $value = 1
returns $this

Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subCenturyNoOverflow

no arguments
returns $this

Sub one century to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addDecades

int|float $value = 1
returns $this

Add decades (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addDecade

no arguments
returns $this

Add one decade to the instance (using date interval).

Method added2.0.0no arguments

Carbon::subDecades

int|float $value = 1
returns $this

Sub decades (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subDecade

no arguments
returns $this

Sub one decade to the instance (using date interval).

Method added2.0.0no arguments

Carbon::addDecadesWithOverflow

int|float $value = 1
returns $this

Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addDecadeWithOverflow

no arguments
returns $this

Add one decade to the instance (using date interval) with overflow explicitly allowed.

Method added2.0.0no arguments

Carbon::subDecadesWithOverflow

int|float $value = 1
returns $this

Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subDecadeWithOverflow

no arguments
returns $this

Sub one decade to the instance (using date interval) with overflow explicitly allowed.

Method added2.0.0no arguments

Carbon::addDecadesWithoutOverflow

int|float $value = 1
returns $this

Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addDecadeWithoutOverflow

no arguments
returns $this

Add one decade to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subDecadesWithoutOverflow

int|float $value = 1
returns $this

Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subDecadeWithoutOverflow

no arguments
returns $this

Sub one decade to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addDecadesWithNoOverflow

int|float $value = 1
returns $this

Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addDecadeWithNoOverflow

no arguments
returns $this

Add one decade to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subDecadesWithNoOverflow

int|float $value = 1
returns $this

Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subDecadeWithNoOverflow

no arguments
returns $this

Sub one decade to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addDecadesNoOverflow

int|float $value = 1
returns $this

Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addDecadeNoOverflow

no arguments
returns $this

Add one decade to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subDecadesNoOverflow

int|float $value = 1
returns $this

Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subDecadeNoOverflow

no arguments
returns $this

Sub one decade to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addQuarters

int|float $value = 1
returns $this

Add quarters (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.22.0$value

Carbon::addQuarter

no arguments
returns $this

Add one quarter to the instance (using date interval).

Prototype changed2.0.0no arguments
Method added1.22.0$value = 1

Carbon::subQuarters

int|float $value = 1
returns $this

Sub quarters (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.22.0$value

Carbon::subQuarter

no arguments
returns $this

Sub one quarter to the instance (using date interval).

Prototype changed2.0.0no arguments
Method added1.22.0$value = 1

Carbon::addQuartersWithOverflow

int|float $value = 1
returns $this

Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addQuarterWithOverflow

no arguments
returns $this

Add one quarter to the instance (using date interval) with overflow explicitly allowed.

Method added2.0.0no arguments

Carbon::subQuartersWithOverflow

int|float $value = 1
returns $this

Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subQuarterWithOverflow

no arguments
returns $this

Sub one quarter to the instance (using date interval) with overflow explicitly allowed.

Method added2.0.0no arguments

Carbon::addQuartersWithoutOverflow

int|float $value = 1
returns $this

Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addQuarterWithoutOverflow

no arguments
returns $this

Add one quarter to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subQuartersWithoutOverflow

int|float $value = 1
returns $this

Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subQuarterWithoutOverflow

no arguments
returns $this

Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addQuartersWithNoOverflow

int|float $value = 1
returns $this

Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addQuarterWithNoOverflow

no arguments
returns $this

Add one quarter to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subQuartersWithNoOverflow

int|float $value = 1
returns $this

Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subQuarterWithNoOverflow

no arguments
returns $this

Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addQuartersNoOverflow

int|float $value = 1
returns $this

Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::addQuarterNoOverflow

no arguments
returns $this

Add one quarter to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::subQuartersNoOverflow

int|float $value = 1
returns $this

Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden.

Prototype changed3.0.0int|float $value = 1
Method added2.0.0int $value = 1

Carbon::subQuarterNoOverflow

no arguments
returns $this

Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.

Method added2.0.0no arguments

Carbon::addWeeks

int|float $value = 1
returns $this

Add weeks (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::addWeek

no arguments
returns $this

Add one week to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::subWeeks

int|float $value = 1
returns $this

Sub weeks (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::subWeek

no arguments
returns $this

Sub one week to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::addWeekdays

int|float $value = 1
returns $this

Add weekdays (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::addWeekday

no arguments
returns $this

Add one weekday to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::subWeekdays

int|float $value = 1
returns $this

Sub weekdays (the $value count passed in) to the instance (using date interval).

Prototype changed3.0.0int|float $value = 1
Prototype changed2.0.0int $value = 1
Method added1.0.0$value

Carbon::subWeekday

no arguments
returns $this

Sub one weekday to the instance (using date interval).

Prototype changed2.0.0no arguments
Prototype changed1.18.0$value = 1
Method added1.0.0no arguments

Carbon::addUTCMicros

int|float $value = 1
returns $this

Add microseconds (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCMicro

no arguments
returns $this

Add one microsecond to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCMicros

int|float $value = 1
returns $this

Sub microseconds (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCMicro

no arguments
returns $this

Sub one microsecond to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::microsUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCMicros

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of microseconds.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::addUTCMicroseconds

int|float $value = 1
returns $this

Add microseconds (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCMicrosecond

no arguments
returns $this

Add one microsecond to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCMicroseconds

int|float $value = 1
returns $this

Sub microseconds (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCMicrosecond

no arguments
returns $this

Sub one microsecond to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::microsecondsUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCMicroseconds

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of microseconds.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::addUTCMillis

int|float $value = 1
returns $this

Add milliseconds (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCMilli

no arguments
returns $this

Add one millisecond to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCMillis

int|float $value = 1
returns $this

Sub milliseconds (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCMilli

no arguments
returns $this

Sub one millisecond to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::millisUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCMillis

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of milliseconds.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::addUTCMilliseconds

int|float $value = 1
returns $this

Add milliseconds (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCMillisecond

no arguments
returns $this

Add one millisecond to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCMilliseconds

int|float $value = 1
returns $this

Sub milliseconds (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCMillisecond

no arguments
returns $this

Sub one millisecond to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::millisecondsUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCMilliseconds

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of milliseconds.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::addUTCSeconds

int|float $value = 1
returns $this

Add seconds (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCSecond

no arguments
returns $this

Add one second to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCSeconds

int|float $value = 1
returns $this

Sub seconds (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCSecond

no arguments
returns $this

Sub one second to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::secondsUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCSeconds

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of seconds.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::addUTCMinutes

int|float $value = 1
returns $this

Add minutes (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCMinute

no arguments
returns $this

Add one minute to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCMinutes

int|float $value = 1
returns $this

Sub minutes (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCMinute

no arguments
returns $this

Sub one minute to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::minutesUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCMinutes

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of minutes.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::addUTCHours

int|float $value = 1
returns $this

Add hours (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCHour

no arguments
returns $this

Add one hour to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCHours

int|float $value = 1
returns $this

Sub hours (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCHour

no arguments
returns $this

Sub one hour to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::hoursUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCHours

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of hours.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::addUTCDays

int|float $value = 1
returns $this

Add days (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCDay

no arguments
returns $this

Add one day to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCDays

int|float $value = 1
returns $this

Sub days (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCDay

no arguments
returns $this

Sub one day to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::daysUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCDays

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of days.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::addUTCWeeks

int|float $value = 1
returns $this

Add weeks (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCWeek

no arguments
returns $this

Add one week to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCWeeks

int|float $value = 1
returns $this

Sub weeks (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCWeek

no arguments
returns $this

Sub one week to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::weeksUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCWeeks

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of weeks.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::addUTCMonths

int|float $value = 1
returns $this

Add months (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCMonth

no arguments
returns $this

Add one month to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCMonths

int|float $value = 1
returns $this

Sub months (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCMonth

no arguments
returns $this

Sub one month to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::monthsUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCMonths

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of months.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::addUTCQuarters

int|float $value = 1
returns $this

Add quarters (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCQuarter

no arguments
returns $this

Add one quarter to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCQuarters

int|float $value = 1
returns $this

Sub quarters (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCQuarter

no arguments
returns $this

Sub one quarter to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::quartersUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCQuarters

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of quarters.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::addUTCYears

int|float $value = 1
returns $this

Add years (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCYear

no arguments
returns $this

Add one year to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCYears

int|float $value = 1
returns $this

Sub years (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCYear

no arguments
returns $this

Sub one year to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::yearsUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCYears

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of years.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::addUTCDecades

int|float $value = 1
returns $this

Add decades (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCDecade

no arguments
returns $this

Add one decade to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCDecades

int|float $value = 1
returns $this

Sub decades (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCDecade

no arguments
returns $this

Sub one decade to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::decadesUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCDecades

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of decades.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::addUTCCenturies

int|float $value = 1
returns $this

Add centuries (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCCentury

no arguments
returns $this

Add one century to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCCenturies

int|float $value = 1
returns $this

Sub centuries (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCCentury

no arguments
returns $this

Sub one century to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::centuriesUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCCenturies

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of centuries.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::addUTCMillennia

int|float $value = 1
returns $this

Add millennia (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::addUTCMillennium

no arguments
returns $this

Add one millennium to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::subUTCMillennia

int|float $value = 1
returns $this

Sub millennia (the $value count passed in) to the instance (using timestamp).

Method added3.2.0int|float $value = 1

Carbon::subUTCMillennium

no arguments
returns $this

Sub one millennium to the instance (using timestamp).

Method added3.2.0no arguments

Carbon::millenniaUntil

$endDate = null, int|float $factor = 1
returns CarbonPeriod

Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given.

Prototype changed3.0.0$endDate = null, int|float $factor = 1
Method added2.20.0$endDate = null, int $factor = 1

Carbon::diffInUTCMillennia

DateTimeInterface|string|null $date, bool $absolute = false
returns float

Convert current and given date in UTC timezone and return a floating number of millennia.

Method added3.2.0DateTimeInterface|string|null $date, bool $absolute = false

Carbon::roundYear

float $precision = 1, string $function = "round"
returns $this

Round the current instance year with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::roundYears

float $precision = 1, string $function = "round"
returns $this

Round the current instance year with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::floorYear

float $precision = 1
returns $this

Truncate the current instance year with given precision.

Method added2.0.0float $precision = 1

Carbon::floorYears

float $precision = 1
returns $this

Truncate the current instance year with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilYear

float $precision = 1
returns $this

Ceil the current instance year with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilYears

float $precision = 1
returns $this

Ceil the current instance year with given precision.

Method added2.0.0float $precision = 1

Carbon::roundMonth

float $precision = 1, string $function = "round"
returns $this

Round the current instance month with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::roundMonths

float $precision = 1, string $function = "round"
returns $this

Round the current instance month with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::floorMonth

float $precision = 1
returns $this

Truncate the current instance month with given precision.

Method added2.0.0float $precision = 1

Carbon::floorMonths

float $precision = 1
returns $this

Truncate the current instance month with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilMonth

float $precision = 1
returns $this

Ceil the current instance month with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilMonths

float $precision = 1
returns $this

Ceil the current instance month with given precision.

Method added2.0.0float $precision = 1

Carbon::roundDay

float $precision = 1, string $function = "round"
returns $this

Round the current instance day with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::roundDays

float $precision = 1, string $function = "round"
returns $this

Round the current instance day with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::floorDay

float $precision = 1
returns $this

Truncate the current instance day with given precision.

Method added2.0.0float $precision = 1

Carbon::floorDays

float $precision = 1
returns $this

Truncate the current instance day with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilDay

float $precision = 1
returns $this

Ceil the current instance day with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilDays

float $precision = 1
returns $this

Ceil the current instance day with given precision.

Method added2.0.0float $precision = 1

Carbon::roundHour

float $precision = 1, string $function = "round"
returns $this

Round the current instance hour with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::roundHours

float $precision = 1, string $function = "round"
returns $this

Round the current instance hour with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::floorHour

float $precision = 1
returns $this

Truncate the current instance hour with given precision.

Method added2.0.0float $precision = 1

Carbon::floorHours

float $precision = 1
returns $this

Truncate the current instance hour with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilHour

float $precision = 1
returns $this

Ceil the current instance hour with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilHours

float $precision = 1
returns $this

Ceil the current instance hour with given precision.

Method added2.0.0float $precision = 1

Carbon::roundMinute

float $precision = 1, string $function = "round"
returns $this

Round the current instance minute with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::roundMinutes

float $precision = 1, string $function = "round"
returns $this

Round the current instance minute with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::floorMinute

float $precision = 1
returns $this

Truncate the current instance minute with given precision.

Method added2.0.0float $precision = 1

Carbon::floorMinutes

float $precision = 1
returns $this

Truncate the current instance minute with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilMinute

float $precision = 1
returns $this

Ceil the current instance minute with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilMinutes

float $precision = 1
returns $this

Ceil the current instance minute with given precision.

Method added2.0.0float $precision = 1

Carbon::roundSecond

float $precision = 1, string $function = "round"
returns $this

Round the current instance second with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::roundSeconds

float $precision = 1, string $function = "round"
returns $this

Round the current instance second with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::floorSecond

float $precision = 1
returns $this

Truncate the current instance second with given precision.

Method added2.0.0float $precision = 1

Carbon::floorSeconds

float $precision = 1
returns $this

Truncate the current instance second with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilSecond

float $precision = 1
returns $this

Ceil the current instance second with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilSeconds

float $precision = 1
returns $this

Ceil the current instance second with given precision.

Method added2.0.0float $precision = 1

Carbon::roundMillennium

float $precision = 1, string $function = "round"
returns $this

Round the current instance millennium with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::roundMillennia

float $precision = 1, string $function = "round"
returns $this

Round the current instance millennium with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::floorMillennium

float $precision = 1
returns $this

Truncate the current instance millennium with given precision.

Method added2.0.0float $precision = 1

Carbon::floorMillennia

float $precision = 1
returns $this

Truncate the current instance millennium with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilMillennium

float $precision = 1
returns $this

Ceil the current instance millennium with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilMillennia

float $precision = 1
returns $this

Ceil the current instance millennium with given precision.

Method added2.0.0float $precision = 1

Carbon::roundCentury

float $precision = 1, string $function = "round"
returns $this

Round the current instance century with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::roundCenturies

float $precision = 1, string $function = "round"
returns $this

Round the current instance century with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::floorCentury

float $precision = 1
returns $this

Truncate the current instance century with given precision.

Method added2.0.0float $precision = 1

Carbon::floorCenturies

float $precision = 1
returns $this

Truncate the current instance century with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilCentury

float $precision = 1
returns $this

Ceil the current instance century with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilCenturies

float $precision = 1
returns $this

Ceil the current instance century with given precision.

Method added2.0.0float $precision = 1

Carbon::roundDecade

float $precision = 1, string $function = "round"
returns $this

Round the current instance decade with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::roundDecades

float $precision = 1, string $function = "round"
returns $this

Round the current instance decade with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::floorDecade

float $precision = 1
returns $this

Truncate the current instance decade with given precision.

Method added2.0.0float $precision = 1

Carbon::floorDecades

float $precision = 1
returns $this

Truncate the current instance decade with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilDecade

float $precision = 1
returns $this

Ceil the current instance decade with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilDecades

float $precision = 1
returns $this

Ceil the current instance decade with given precision.

Method added2.0.0float $precision = 1

Carbon::roundQuarter

float $precision = 1, string $function = "round"
returns $this

Round the current instance quarter with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::roundQuarters

float $precision = 1, string $function = "round"
returns $this

Round the current instance quarter with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::floorQuarter

float $precision = 1
returns $this

Truncate the current instance quarter with given precision.

Method added2.0.0float $precision = 1

Carbon::floorQuarters

float $precision = 1
returns $this

Truncate the current instance quarter with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilQuarter

float $precision = 1
returns $this

Ceil the current instance quarter with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilQuarters

float $precision = 1
returns $this

Ceil the current instance quarter with given precision.

Method added2.0.0float $precision = 1

Carbon::roundMillisecond

float $precision = 1, string $function = "round"
returns $this

Round the current instance millisecond with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::roundMilliseconds

float $precision = 1, string $function = "round"
returns $this

Round the current instance millisecond with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::floorMillisecond

float $precision = 1
returns $this

Truncate the current instance millisecond with given precision.

Method added2.0.0float $precision = 1

Carbon::floorMilliseconds

float $precision = 1
returns $this

Truncate the current instance millisecond with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilMillisecond

float $precision = 1
returns $this

Ceil the current instance millisecond with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilMilliseconds

float $precision = 1
returns $this

Ceil the current instance millisecond with given precision.

Method added2.0.0float $precision = 1

Carbon::roundMicrosecond

float $precision = 1, string $function = "round"
returns $this

Round the current instance microsecond with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::roundMicroseconds

float $precision = 1, string $function = "round"
returns $this

Round the current instance microsecond with given precision using the given function.

Method added2.0.0float $precision = 1, string $function = "round"

Carbon::floorMicrosecond

float $precision = 1
returns $this

Truncate the current instance microsecond with given precision.

Method added2.0.0float $precision = 1

Carbon::floorMicroseconds

float $precision = 1
returns $this

Truncate the current instance microsecond with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilMicrosecond

float $precision = 1
returns $this

Ceil the current instance microsecond with given precision.

Method added2.0.0float $precision = 1

Carbon::ceilMicroseconds

float $precision = 1
returns $this

Ceil the current instance microsecond with given precision.

Method added2.0.0float $precision = 1

Carbon::shortAbsoluteDiffForHumans

DateTimeInterface $other = null, int $parts = 1
returns string

Get the difference (short format, 'Absolute' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)

Prototype changed2.34.2DateTimeInterface $other = null, int $parts = 1
Method added2.0.0\DateTimeInterface $other = null, int $parts = 1

Carbon::longAbsoluteDiffForHumans

DateTimeInterface $other = null, int $parts = 1
returns string

Get the difference (long format, 'Absolute' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)

Prototype changed2.34.2DateTimeInterface $other = null, int $parts = 1
Method added2.0.0\DateTimeInterface $other = null, int $parts = 1

Carbon::shortRelativeDiffForHumans

DateTimeInterface $other = null, int $parts = 1
returns string

Get the difference (short format, 'Relative' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)

Prototype changed2.34.2DateTimeInterface $other = null, int $parts = 1
Method added2.0.0\DateTimeInterface $other = null, int $parts = 1

Carbon::longRelativeDiffForHumans

DateTimeInterface $other = null, int $parts = 1
returns string

Get the difference (long format, 'Relative' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)

Prototype changed2.34.2DateTimeInterface $other = null, int $parts = 1
Method added2.0.0\DateTimeInterface $other = null, int $parts = 1

Carbon::shortRelativeToNowDiffForHumans

DateTimeInterface $other = null, int $parts = 1
returns string

Get the difference (short format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)

Prototype changed2.34.2DateTimeInterface $other = null, int $parts = 1
Method added2.0.0\DateTimeInterface $other = null, int $parts = 1

Carbon::longRelativeToNowDiffForHumans

DateTimeInterface $other = null, int $parts = 1
returns string

Get the difference (long format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)

Prototype changed2.34.2DateTimeInterface $other = null, int $parts = 1
Method added2.0.0\DateTimeInterface $other = null, int $parts = 1

Carbon::shortRelativeToOtherDiffForHumans

DateTimeInterface $other = null, int $parts = 1
returns string

Get the difference (short format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)

Prototype changed2.34.2DateTimeInterface $other = null, int $parts = 1
Method added2.0.0\DateTimeInterface $other = null, int $parts = 1

Carbon::longRelativeToOtherDiffForHumans

DateTimeInterface $other = null, int $parts = 1
returns string

Get the difference (long format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.)

Prototype changed2.34.2DateTimeInterface $other = null, int $parts = 1
Method added2.0.0\DateTimeInterface $other = null, int $parts = 1

Carbon::centuriesInMillennium

no arguments
returns int

Return the number of centuries contained in the current millennium

Method added3.0.0no arguments

Carbon::centuryOfMillennium

?int $century = null
returns int|static

Return the value of the century starting from the beginning of the current millennium when called with no parameters, change the current century when called with an integer value

Method added3.0.0?int $century = null

Carbon::dayOfCentury

?int $day = null
returns int|static

Return the value of the day starting from the beginning of the current century when called with no parameters, change the current day when called with an integer value

Method added3.0.0?int $day = null

Carbon::dayOfDecade

?int $day = null
returns int|static

Return the value of the day starting from the beginning of the current decade when called with no parameters, change the current day when called with an integer value

Method added3.0.0?int $day = null

Carbon::dayOfMillennium

?int $day = null
returns int|static

Return the value of the day starting from the beginning of the current millennium when called with no parameters, change the current day when called with an integer value

Method added3.0.0?int $day = null

Carbon::dayOfMonth

?int $day = null
returns int|static

Return the value of the day starting from the beginning of the current month when called with no parameters, change the current day when called with an integer value

Method added3.0.0?int $day = null

Carbon::dayOfQuarter

?int $day = null
returns int|static

Return the value of the day starting from the beginning of the current quarter when called with no parameters, change the current day when called with an integer value

Method added3.0.0?int $day = null

Carbon::dayOfWeek

?int $day = null
returns int|static

Return the value of the day starting from the beginning of the current week when called with no parameters, change the current day when called with an integer value

Method added3.0.0?int $day = null

Carbon::daysInCentury

no arguments
returns int

Return the number of days contained in the current century

Method added3.0.0no arguments

Carbon::daysInDecade

no arguments
returns int

Return the number of days contained in the current decade

Method added3.0.0no arguments

Carbon::daysInMillennium

no arguments
returns int

Return the number of days contained in the current millennium

Method added3.0.0no arguments

Carbon::daysInMonth

no arguments
returns int

Return the number of days contained in the current month

Method added3.0.0no arguments

Carbon::daysInQuarter

no arguments
returns int

Return the number of days contained in the current quarter

Method added3.0.0no arguments

Carbon::daysInWeek

no arguments
returns int

Return the number of days contained in the current week

Method added3.0.0no arguments

Carbon::daysInYear

no arguments
returns int

Return the number of days contained in the current year

Method added3.0.0no arguments

Carbon::decadeOfCentury

?int $decade = null
returns int|static

Return the value of the decade starting from the beginning of the current century when called with no parameters, change the current decade when called with an integer value

Method added3.0.0?int $decade = null

Carbon::decadeOfMillennium

?int $decade = null
returns int|static

Return the value of the decade starting from the beginning of the current millennium when called with no parameters, change the current decade when called with an integer value

Method added3.0.0?int $decade = null

Carbon::decadesInCentury

no arguments
returns int

Return the number of decades contained in the current century

Method added3.0.0no arguments

Carbon::decadesInMillennium

no arguments
returns int

Return the number of decades contained in the current millennium

Method added3.0.0no arguments

Carbon::hourOfCentury

?int $hour = null
returns int|static

Return the value of the hour starting from the beginning of the current century when called with no parameters, change the current hour when called with an integer value

Method added3.0.0?int $hour = null

Carbon::hourOfDay

?int $hour = null
returns int|static

Return the value of the hour starting from the beginning of the current day when called with no parameters, change the current hour when called with an integer value

Method added3.0.0?int $hour = null

Carbon::hourOfDecade

?int $hour = null
returns int|static

Return the value of the hour starting from the beginning of the current decade when called with no parameters, change the current hour when called with an integer value

Method added3.0.0?int $hour = null

Carbon::hourOfMillennium

?int $hour = null
returns int|static

Return the value of the hour starting from the beginning of the current millennium when called with no parameters, change the current hour when called with an integer value

Method added3.0.0?int $hour = null

Carbon::hourOfMonth

?int $hour = null
returns int|static

Return the value of the hour starting from the beginning of the current month when called with no parameters, change the current hour when called with an integer value

Method added3.0.0?int $hour = null

Carbon::hourOfQuarter

?int $hour = null
returns int|static

Return the value of the hour starting from the beginning of the current quarter when called with no parameters, change the current hour when called with an integer value

Method added3.0.0?int $hour = null

Carbon::hourOfWeek

?int $hour = null
returns int|static

Return the value of the hour starting from the beginning of the current week when called with no parameters, change the current hour when called with an integer value

Method added3.0.0?int $hour = null

Carbon::hourOfYear

?int $hour = null
returns int|static

Return the value of the hour starting from the beginning of the current year when called with no parameters, change the current hour when called with an integer value

Method added3.0.0?int $hour = null

Carbon::hoursInCentury

no arguments
returns int

Return the number of hours contained in the current century

Method added3.0.0no arguments

Carbon::hoursInDay

no arguments
returns int

Return the number of hours contained in the current day

Method added3.0.0no arguments

Carbon::hoursInDecade

no arguments
returns int

Return the number of hours contained in the current decade

Method added3.0.0no arguments

Carbon::hoursInMillennium

no arguments
returns int

Return the number of hours contained in the current millennium

Method added3.0.0no arguments

Carbon::hoursInMonth

no arguments
returns int

Return the number of hours contained in the current month

Method added3.0.0no arguments

Carbon::hoursInQuarter

no arguments
returns int

Return the number of hours contained in the current quarter

Method added3.0.0no arguments

Carbon::hoursInWeek

no arguments
returns int

Return the number of hours contained in the current week

Method added3.0.0no arguments

Carbon::hoursInYear

no arguments
returns int

Return the number of hours contained in the current year

Method added3.0.0no arguments

Carbon::microsecondOfCentury

?int $microsecond = null
returns int|static

Return the value of the microsecond starting from the beginning of the current century when called with no parameters, change the current microsecond when called with an integer value

Method added3.0.0?int $microsecond = null

Carbon::microsecondOfDay

?int $microsecond = null
returns int|static

Return the value of the microsecond starting from the beginning of the current day when called with no parameters, change the current microsecond when called with an integer value

Method added3.0.0?int $microsecond = null

Carbon::microsecondOfDecade

?int $microsecond = null
returns int|static

Return the value of the microsecond starting from the beginning of the current decade when called with no parameters, change the current microsecond when called with an integer value

Method added3.0.0?int $microsecond = null

Carbon::microsecondOfHour

?int $microsecond = null
returns int|static

Return the value of the microsecond starting from the beginning of the current hour when called with no parameters, change the current microsecond when called with an integer value

Method added3.0.0?int $microsecond = null

Carbon::microsecondOfMillennium

?int $microsecond = null
returns int|static

Return the value of the microsecond starting from the beginning of the current millennium when called with no parameters, change the current microsecond when called with an integer value

Method added3.0.0?int $microsecond = null

Carbon::microsecondOfMillisecond

?int $microsecond = null
returns int|static

Return the value of the microsecond starting from the beginning of the current millisecond when called with no parameters, change the current microsecond when called with an integer value

Method added3.0.0?int $microsecond = null

Carbon::microsecondOfMinute

?int $microsecond = null
returns int|static

Return the value of the microsecond starting from the beginning of the current minute when called with no parameters, change the current microsecond when called with an integer value

Method added3.0.0?int $microsecond = null

Carbon::microsecondOfMonth

?int $microsecond = null
returns int|static

Return the value of the microsecond starting from the beginning of the current month when called with no parameters, change the current microsecond when called with an integer value

Method added3.0.0?int $microsecond = null

Carbon::microsecondOfQuarter

?int $microsecond = null
returns int|static

Return the value of the microsecond starting from the beginning of the current quarter when called with no parameters, change the current microsecond when called with an integer value

Method added3.0.0?int $microsecond = null

Carbon::microsecondOfSecond

?int $microsecond = null
returns int|static

Return the value of the microsecond starting from the beginning of the current second when called with no parameters, change the current microsecond when called with an integer value

Method added3.0.0?int $microsecond = null

Carbon::microsecondOfWeek

?int $microsecond = null
returns int|static

Return the value of the microsecond starting from the beginning of the current week when called with no parameters, change the current microsecond when called with an integer value

Method added3.0.0?int $microsecond = null

Carbon::microsecondOfYear

?int $microsecond = null
returns int|static

Return the value of the microsecond starting from the beginning of the current year when called with no parameters, change the current microsecond when called with an integer value

Method added3.0.0?int $microsecond = null

Carbon::microsecondsInCentury

no arguments
returns int

Return the number of microseconds contained in the current century

Method added3.0.0no arguments

Carbon::microsecondsInDay

no arguments
returns int

Return the number of microseconds contained in the current day

Method added3.0.0no arguments

Carbon::microsecondsInDecade

no arguments
returns int

Return the number of microseconds contained in the current decade

Method added3.0.0no arguments

Carbon::microsecondsInHour

no arguments
returns int

Return the number of microseconds contained in the current hour

Method added3.0.0no arguments

Carbon::microsecondsInMillennium

no arguments
returns int

Return the number of microseconds contained in the current millennium

Method added3.0.0no arguments

Carbon::microsecondsInMillisecond

no arguments
returns int

Return the number of microseconds contained in the current millisecond

Method added3.0.0no arguments

Carbon::microsecondsInMinute

no arguments
returns int

Return the number of microseconds contained in the current minute

Method added3.0.0no arguments

Carbon::microsecondsInMonth

no arguments
returns int

Return the number of microseconds contained in the current month

Method added3.0.0no arguments

Carbon::microsecondsInQuarter

no arguments
returns int

Return the number of microseconds contained in the current quarter

Method added3.0.0no arguments

Carbon::microsecondsInSecond

no arguments
returns int

Return the number of microseconds contained in the current second

Method added3.0.0no arguments

Carbon::microsecondsInWeek

no arguments
returns int

Return the number of microseconds contained in the current week

Method added3.0.0no arguments

Carbon::microsecondsInYear

no arguments
returns int

Return the number of microseconds contained in the current year

Method added3.0.0no arguments

Carbon::millisecondOfCentury

?int $millisecond = null
returns int|static

Return the value of the millisecond starting from the beginning of the current century when called with no parameters, change the current millisecond when called with an integer value

Method added3.0.0?int $millisecond = null

Carbon::millisecondOfDay

?int $millisecond = null
returns int|static

Return the value of the millisecond starting from the beginning of the current day when called with no parameters, change the current millisecond when called with an integer value

Method added3.0.0?int $millisecond = null

Carbon::millisecondOfDecade

?int $millisecond = null
returns int|static

Return the value of the millisecond starting from the beginning of the current decade when called with no parameters, change the current millisecond when called with an integer value

Method added3.0.0?int $millisecond = null

Carbon::millisecondOfHour

?int $millisecond = null
returns int|static

Return the value of the millisecond starting from the beginning of the current hour when called with no parameters, change the current millisecond when called with an integer value

Method added3.0.0?int $millisecond = null

Carbon::millisecondOfMillennium

?int $millisecond = null
returns int|static

Return the value of the millisecond starting from the beginning of the current millennium when called with no parameters, change the current millisecond when called with an integer value

Method added3.0.0?int $millisecond = null

Carbon::millisecondOfMinute

?int $millisecond = null
returns int|static

Return the value of the millisecond starting from the beginning of the current minute when called with no parameters, change the current millisecond when called with an integer value

Method added3.0.0?int $millisecond = null

Carbon::millisecondOfMonth

?int $millisecond = null
returns int|static

Return the value of the millisecond starting from the beginning of the current month when called with no parameters, change the current millisecond when called with an integer value

Method added3.0.0?int $millisecond = null

Carbon::millisecondOfQuarter

?int $millisecond = null
returns int|static

Return the value of the millisecond starting from the beginning of the current quarter when called with no parameters, change the current millisecond when called with an integer value

Method added3.0.0?int $millisecond = null

Carbon::millisecondOfSecond

?int $millisecond = null
returns int|static

Return the value of the millisecond starting from the beginning of the current second when called with no parameters, change the current millisecond when called with an integer value

Method added3.0.0?int $millisecond = null

Carbon::millisecondOfWeek

?int $millisecond = null
returns int|static

Return the value of the millisecond starting from the beginning of the current week when called with no parameters, change the current millisecond when called with an integer value

Method added3.0.0?int $millisecond = null

Carbon::millisecondOfYear

?int $millisecond = null
returns int|static

Return the value of the millisecond starting from the beginning of the current year when called with no parameters, change the current millisecond when called with an integer value

Method added3.0.0?int $millisecond = null

Carbon::millisecondsInCentury

no arguments
returns int

Return the number of milliseconds contained in the current century

Method added3.0.0no arguments

Carbon::millisecondsInDay

no arguments
returns int

Return the number of milliseconds contained in the current day

Method added3.0.0no arguments

Carbon::millisecondsInDecade

no arguments
returns int

Return the number of milliseconds contained in the current decade

Method added3.0.0no arguments

Carbon::millisecondsInHour

no arguments
returns int

Return the number of milliseconds contained in the current hour

Method added3.0.0no arguments

Carbon::millisecondsInMillennium

no arguments
returns int

Return the number of milliseconds contained in the current millennium

Method added3.0.0no arguments

Carbon::millisecondsInMinute

no arguments
returns int

Return the number of milliseconds contained in the current minute

Method added3.0.0no arguments

Carbon::millisecondsInMonth

no arguments
returns int

Return the number of milliseconds contained in the current month

Method added3.0.0no arguments

Carbon::millisecondsInQuarter

no arguments
returns int

Return the number of milliseconds contained in the current quarter

Method added3.0.0no arguments

Carbon::millisecondsInSecond

no arguments
returns int

Return the number of milliseconds contained in the current second

Method added3.0.0no arguments

Carbon::millisecondsInWeek

no arguments
returns int

Return the number of milliseconds contained in the current week

Method added3.0.0no arguments

Carbon::millisecondsInYear

no arguments
returns int

Return the number of milliseconds contained in the current year

Method added3.0.0no arguments

Carbon::minuteOfCentury

?int $minute = null
returns int|static

Return the value of the minute starting from the beginning of the current century when called with no parameters, change the current minute when called with an integer value

Method added3.0.0?int $minute = null

Carbon::minuteOfDay

?int $minute = null
returns int|static

Return the value of the minute starting from the beginning of the current day when called with no parameters, change the current minute when called with an integer value

Method added3.0.0?int $minute = null

Carbon::minuteOfDecade

?int $minute = null
returns int|static

Return the value of the minute starting from the beginning of the current decade when called with no parameters, change the current minute when called with an integer value

Method added3.0.0?int $minute = null

Carbon::minuteOfHour

?int $minute = null
returns int|static

Return the value of the minute starting from the beginning of the current hour when called with no parameters, change the current minute when called with an integer value

Method added3.0.0?int $minute = null

Carbon::minuteOfMillennium

?int $minute = null
returns int|static

Return the value of the minute starting from the beginning of the current millennium when called with no parameters, change the current minute when called with an integer value

Method added3.0.0?int $minute = null

Carbon::minuteOfMonth

?int $minute = null
returns int|static

Return the value of the minute starting from the beginning of the current month when called with no parameters, change the current minute when called with an integer value

Method added3.0.0?int $minute = null

Carbon::minuteOfQuarter

?int $minute = null
returns int|static

Return the value of the minute starting from the beginning of the current quarter when called with no parameters, change the current minute when called with an integer value

Method added3.0.0?int $minute = null

Carbon::minuteOfWeek

?int $minute = null
returns int|static

Return the value of the minute starting from the beginning of the current week when called with no parameters, change the current minute when called with an integer value

Method added3.0.0?int $minute = null

Carbon::minuteOfYear

?int $minute = null
returns int|static

Return the value of the minute starting from the beginning of the current year when called with no parameters, change the current minute when called with an integer value

Method added3.0.0?int $minute = null

Carbon::minutesInCentury

no arguments
returns int

Return the number of minutes contained in the current century

Method added3.0.0no arguments

Carbon::minutesInDay

no arguments
returns int

Return the number of minutes contained in the current day

Method added3.0.0no arguments

Carbon::minutesInDecade

no arguments
returns int

Return the number of minutes contained in the current decade

Method added3.0.0no arguments

Carbon::minutesInHour

no arguments
returns int

Return the number of minutes contained in the current hour

Method added3.0.0no arguments

Carbon::minutesInMillennium

no arguments
returns int

Return the number of minutes contained in the current millennium

Method added3.0.0no arguments

Carbon::minutesInMonth

no arguments
returns int

Return the number of minutes contained in the current month

Method added3.0.0no arguments

Carbon::minutesInQuarter

no arguments
returns int

Return the number of minutes contained in the current quarter

Method added3.0.0no arguments

Carbon::minutesInWeek

no arguments
returns int

Return the number of minutes contained in the current week

Method added3.0.0no arguments

Carbon::minutesInYear

no arguments
returns int

Return the number of minutes contained in the current year

Method added3.0.0no arguments

Carbon::monthOfCentury

?int $month = null
returns int|static

Return the value of the month starting from the beginning of the current century when called with no parameters, change the current month when called with an integer value

Method added3.0.0?int $month = null

Carbon::monthOfDecade

?int $month = null
returns int|static

Return the value of the month starting from the beginning of the current decade when called with no parameters, change the current month when called with an integer value

Method added3.0.0?int $month = null

Carbon::monthOfMillennium

?int $month = null
returns int|static

Return the value of the month starting from the beginning of the current millennium when called with no parameters, change the current month when called with an integer value

Method added3.0.0?int $month = null

Carbon::monthOfQuarter

?int $month = null
returns int|static

Return the value of the month starting from the beginning of the current quarter when called with no parameters, change the current month when called with an integer value

Method added3.0.0?int $month = null

Carbon::monthOfYear

?int $month = null
returns int|static

Return the value of the month starting from the beginning of the current year when called with no parameters, change the current month when called with an integer value

Method added3.0.0?int $month = null

Carbon::monthsInCentury

no arguments
returns int

Return the number of months contained in the current century

Method added3.0.0no arguments

Carbon::monthsInDecade

no arguments
returns int

Return the number of months contained in the current decade

Method added3.0.0no arguments

Carbon::monthsInMillennium

no arguments
returns int

Return the number of months contained in the current millennium

Method added3.0.0no arguments

Carbon::monthsInQuarter

no arguments
returns int

Return the number of months contained in the current quarter

Method added3.0.0no arguments

Carbon::monthsInYear

no arguments
returns int

Return the number of months contained in the current year

Method added3.0.0no arguments

Carbon::quarterOfCentury

?int $quarter = null
returns int|static

Return the value of the quarter starting from the beginning of the current century when called with no parameters, change the current quarter when called with an integer value

Method added3.0.0?int $quarter = null

Carbon::quarterOfDecade

?int $quarter = null
returns int|static

Return the value of the quarter starting from the beginning of the current decade when called with no parameters, change the current quarter when called with an integer value

Method added3.0.0?int $quarter = null

Carbon::quarterOfMillennium

?int $quarter = null
returns int|static

Return the value of the quarter starting from the beginning of the current millennium when called with no parameters, change the current quarter when called with an integer value

Method added3.0.0?int $quarter = null

Carbon::quarterOfYear

?int $quarter = null
returns int|static

Return the value of the quarter starting from the beginning of the current year when called with no parameters, change the current quarter when called with an integer value

Method added3.0.0?int $quarter = null

Carbon::quartersInCentury

no arguments
returns int

Return the number of quarters contained in the current century

Method added3.0.0no arguments

Carbon::quartersInDecade

no arguments
returns int

Return the number of quarters contained in the current decade

Method added3.0.0no arguments

Carbon::quartersInMillennium

no arguments
returns int

Return the number of quarters contained in the current millennium

Method added3.0.0no arguments

Carbon::quartersInYear

no arguments
returns int

Return the number of quarters contained in the current year

Method added3.0.0no arguments

Carbon::secondOfCentury

?int $second = null
returns int|static

Return the value of the second starting from the beginning of the current century when called with no parameters, change the current second when called with an integer value

Method added3.0.0?int $second = null

Carbon::secondOfDay

?int $second = null
returns int|static

Return the value of the second starting from the beginning of the current day when called with no parameters, change the current second when called with an integer value

Method added3.0.0?int $second = null

Carbon::secondOfDecade

?int $second = null
returns int|static

Return the value of the second starting from the beginning of the current decade when called with no parameters, change the current second when called with an integer value

Method added3.0.0?int $second = null

Carbon::secondOfHour

?int $second = null
returns int|static

Return the value of the second starting from the beginning of the current hour when called with no parameters, change the current second when called with an integer value

Method added3.0.0?int $second = null

Carbon::secondOfMillennium

?int $second = null
returns int|static

Return the value of the second starting from the beginning of the current millennium when called with no parameters, change the current second when called with an integer value

Method added3.0.0?int $second = null

Carbon::secondOfMinute

?int $second = null
returns int|static

Return the value of the second starting from the beginning of the current minute when called with no parameters, change the current second when called with an integer value

Method added3.0.0?int $second = null

Carbon::secondOfMonth

?int $second = null
returns int|static

Return the value of the second starting from the beginning of the current month when called with no parameters, change the current second when called with an integer value

Method added3.0.0?int $second = null

Carbon::secondOfQuarter

?int $second = null
returns int|static

Return the value of the second starting from the beginning of the current quarter when called with no parameters, change the current second when called with an integer value

Method added3.0.0?int $second = null

Carbon::secondOfWeek

?int $second = null
returns int|static

Return the value of the second starting from the beginning of the current week when called with no parameters, change the current second when called with an integer value

Method added3.0.0?int $second = null

Carbon::secondOfYear

?int $second = null
returns int|static

Return the value of the second starting from the beginning of the current year when called with no parameters, change the current second when called with an integer value

Method added3.0.0?int $second = null

Carbon::secondsInCentury

no arguments
returns int

Return the number of seconds contained in the current century

Method added3.0.0no arguments

Carbon::secondsInDay

no arguments
returns int

Return the number of seconds contained in the current day

Method added3.0.0no arguments

Carbon::secondsInDecade

no arguments
returns int

Return the number of seconds contained in the current decade

Method added3.0.0no arguments

Carbon::secondsInHour

no arguments
returns int

Return the number of seconds contained in the current hour

Method added3.0.0no arguments

Carbon::secondsInMillennium

no arguments
returns int

Return the number of seconds contained in the current millennium

Method added3.0.0no arguments

Carbon::secondsInMinute

no arguments
returns int

Return the number of seconds contained in the current minute

Method added3.0.0no arguments

Carbon::secondsInMonth

no arguments
returns int

Return the number of seconds contained in the current month

Method added3.0.0no arguments

Carbon::secondsInQuarter

no arguments
returns int

Return the number of seconds contained in the current quarter

Method added3.0.0no arguments

Carbon::secondsInWeek

no arguments
returns int

Return the number of seconds contained in the current week

Method added3.0.0no arguments

Carbon::secondsInYear

no arguments
returns int

Return the number of seconds contained in the current year

Method added3.0.0no arguments

Carbon::weekOfCentury

?int $week = null
returns int|static

Return the value of the week starting from the beginning of the current century when called with no parameters, change the current week when called with an integer value

Method added3.0.0?int $week = null

Carbon::weekOfDecade

?int $week = null
returns int|static

Return the value of the week starting from the beginning of the current decade when called with no parameters, change the current week when called with an integer value

Method added3.0.0?int $week = null

Carbon::weekOfMillennium

?int $week = null
returns int|static

Return the value of the week starting from the beginning of the current millennium when called with no parameters, change the current week when called with an integer value

Method added3.0.0?int $week = null

Carbon::weekOfMonth

?int $week = null
returns int|static

Return the value of the week starting from the beginning of the current month when called with no parameters, change the current week when called with an integer value

Method added3.0.0?int $week = null

Carbon::weekOfQuarter

?int $week = null
returns int|static

Return the value of the week starting from the beginning of the current quarter when called with no parameters, change the current week when called with an integer value

Method added3.0.0?int $week = null

Carbon::weekOfYear

?int $week = null
returns int|static

Return the value of the week starting from the beginning of the current year when called with no parameters, change the current week when called with an integer value

Method added3.0.0?int $week = null

Carbon::weeksInCentury

no arguments
returns int

Return the number of weeks contained in the current century

Method added3.0.0no arguments

Carbon::weeksInDecade

no arguments
returns int

Return the number of weeks contained in the current decade

Method added3.0.0no arguments

Carbon::weeksInMillennium

no arguments
returns int

Return the number of weeks contained in the current millennium

Method added3.0.0no arguments

Carbon::weeksInMonth

no arguments
returns int

Return the number of weeks contained in the current month

Method added3.0.0no arguments

Carbon::weeksInQuarter

no arguments
returns int

Return the number of weeks contained in the current quarter

Method added3.0.0no arguments

Carbon::yearOfCentury

?int $year = null
returns int|static

Return the value of the year starting from the beginning of the current century when called with no parameters, change the current year when called with an integer value

Method added3.0.0?int $year = null

Carbon::yearOfDecade

?int $year = null
returns int|static

Return the value of the year starting from the beginning of the current decade when called with no parameters, change the current year when called with an integer value

Method added3.0.0?int $year = null

Carbon::yearOfMillennium

?int $year = null
returns int|static

Return the value of the year starting from the beginning of the current millennium when called with no parameters, change the current year when called with an integer value

Method added3.0.0?int $year = null

Carbon::yearsInCentury

no arguments
returns int

Return the number of years contained in the current century

Method added3.0.0no arguments

Carbon::yearsInDecade

no arguments
returns int

Return the number of years contained in the current decade

Method added3.0.0no arguments

Carbon::yearsInMillennium

no arguments
returns int

Return the number of years contained in the current millennium

Method added3.0.0no arguments