Carbon::isMutable
no arguments
returns bool
Returns true if the current class/instance is mutable.
Method added | 2.0.0 | no 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 changed | 3.0.0 | DateTimeInterface|Carbon\WeekDay|Carbon\Month|string|int|float|null $time = null, DateTimeZone|string|int|null $timezone = null |
Method added | 1.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 added | 1.21.0 | no arguments |
Carbon::__unserialize
array $data
Set locale if specified on unserialize() called.
Only used by PHP >= 7.4.
Method added | 1.21.0 | array $data |
Carbon::__wakeup
no arguments
Set locale if specified on unserialize() called.
Only used by PHP < 7.4.
Method added | 1.0.0 | no arguments |
Carbon::__set_state
$dump
returns Carbon
The __set_state handler.
Prototype changed | 2.0.0 | $dump |
Prototype changed | 1.24.2 | $array |
Prototype changed | 1.24.1 | $state |
Prototype changed | 1.24.0 | array $state |
Prototype changed | 1.23.0 | $array |
Method added | 1.0.0 | array $array |
Carbon::getLastErrors
no arguments
returns array|false
{@inheritdoc}
Method added | 1.0.0 | no arguments |
Carbon::modify
$modify
returns Carbon
Calls \DateTime::modify if mutable or \DateTimeImmutable::modify else.
Prototype changed | 2.23.0 | $modify |
Prototype changed | 1.23.0 | string $modifier |
Prototype changed | 1.22.0 | $modify |
Prototype changed | 1.21.0 | string $modifier |
Method added | 1.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 changed | 3.0.0 | $unit, $value = 1, ?bool $overflow = null |
Prototype changed | 2.0.0 | $unit, $value = 1, $overflow = null |
Prototype changed | 1.21.0 | DateInterval $interval |
Method added | 1.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 changed | 3.0.0 | $unit, $value = 1, ?bool $overflow = null |
Prototype changed | 2.0.0 | $unit, $value = 1, $overflow = null |
Prototype changed | 1.21.0 | DateInterval $interval |
Method added | 1.0.0 | $interval |
Carbon::getTimezone
no arguments
returns CarbonTimeZone
Get the TimeZone associated with the Carbon instance (as CarbonTimeZone).
Method added | 1.0.0 | no arguments |
Carbon::setTimezone
DateTimeZone|string|int $timeZone
returns Carbon
Set the instance's timezone from a string or object.
Prototype changed | 3.0.0 | DateTimeZone|string|int $timeZone |
Method added | 1.0.0 | $value |
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 changed | 3.0.0 | int $hour, int $minute, int $second = 0, int $microseconds = 0 |
Prototype changed | 2.23.0 | $hour, $minute, $second = 0, $microseconds = 0 |
Prototype changed | 1.21.0 | int $hour, int $minute, int $second = 0, int $microsecond = 0 |
Prototype changed | 1.15.0 | $hour, $minute, $second, $microseconds |
Method added | 1.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 changed | 3.0.0 | int $year, int $month, int $day |
Prototype changed | 2.23.0 | $year, $month, $day |
Prototype changed | 2.0.0 | int $year, int $month, int $day |
Prototype changed | 1.22.0 | $year, $month, $day |
Prototype changed | 1.21.0 | int $year, int $month, int $day |
Method added | 1.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 changed | 3.0.0 | int $year, int $week, int $day = 1 |
Prototype changed | 2.23.0 | $year, $week, $day = 1 |
Prototype changed | 1.21.0 | int $year, int $week, int $dayOfWeek = 1 |
Method added | 1.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 changed | 3.0.0 | string|int|float $timestamp |
Prototype changed | 2.41.0 | $unixTimestamp |
Prototype changed | 2.23.0 | $unixtimestamp |
Prototype changed | 1.21.0 | int $timestamp |
Method added | 1.0.0 | $unixtimestamp |
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 changed | 3.0.0 | $date = null, bool $absolute = false, array $skip = [] |
Prototype changed | 2.23.0 | $date = null, $absolute = false |
Prototype changed | 1.21.0 | DateTimeInterface $targetObject, bool $absolute = false |
Method added | 1.0.0 | $object, $absolute |
Carbon::copy
no arguments
returns Carbon
Get a copy of the instance.
Method added | 1.0.0 | no arguments |
Carbon::clone
no arguments
returns Carbon
@alias copy
Get a copy of the instance.
Method added | 2.0.0 | no 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 added | 2.50.0 | no arguments |
Carbon::nowWithSameTz
no arguments
returns Carbon
Returns a present instance in the same timezone.
Method added | 1.24.0 | no 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 added | 2.23.0 | $date = null |
Carbon::__get
string $name
returns mixed
Get a part of the Carbon object.
Prototype changed | 3.0.0 | string $name |
Method added | 1.0.0 | $name |
Carbon::get
Carbon\Unit|string $name
returns mixed
Get a part of the Carbon object.
Prototype changed | 3.1.0 | Carbon\Unit|string $name |
Prototype changed | 3.0.0 | string $name |
Method added | 2.0.0 | $name |
Carbon::__isset
$name
returns bool
Check if an attribute exists on the object
Carbon::__set
$name, $value
Set a part of the Carbon object
Method added | 1.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 changed | 3.1.0 | Carbon\Unit|array|string $name, DateTimeZone|Carbon\Month|string|int|float|null $value = null |
Prototype changed | 3.0.0 | array|string $name, DateTimeZone|Carbon\Month|string|int|float|null $value = null |
Method added | 2.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 changed | 3.0.0 | ?string $context = null, string $keySuffix = '', ?string $defaultValue = null |
Method added | 2.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 changed | 3.0.0 | ?string $context = null |
Method added | 2.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 changed | 3.0.0 | ?string $context = null |
Method added | 2.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 changed | 3.0.0 | ?string $context = null, string $keySuffix = '', ?string $defaultValue = null |
Method added | 2.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 changed | 3.0.0 | ?string $context = null |
Method added | 2.4.0 | $context = null |
Carbon::dayOfYear
?int $value = null
returns Carbon|int
Get/set the day of year.
Prototype changed | 3.0.0 | ?int $value = null |
Method added | 2.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 changed | 3.0.0 | Carbon\WeekDay|int|null $value = null |
Method added | 2.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 changed | 3.0.0 | Carbon\WeekDay|int|null $value = null |
Method added | 2.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 changed | 3.0.0 | Carbon\WeekDay|int|null $weekStartsAt = null |
Method added | 2.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 changed | 3.0.0 | int $numberOfDays, Carbon\WeekDay|int|null $weekStartsAt = null |
Method added | 2.64.0 | int $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 changed | 3.0.0 | string $valueUnit, int $value, string $overflowUnit |
Method added | 2.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 changed | 3.0.0 | string $valueUnit, int $value, string $overflowUnit |
Method added | 2.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 changed | 3.0.0 | string $valueUnit, int $value, string $overflowUnit |
Method added | 2.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 changed | 2.44.0 | ?int $minuteOffset = null |
Method added | 2.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 changed | 3.0.0 | int $year, int $month, int $day, int $hour, int $minute, int $second = 0, int $microseconds = 0 |
Prototype changed | 2.0.0 | $year, $month, $day, $hour, $minute, $second = 0, $microseconds = 0 |
Prototype changed | 1.12.0 | $year, $month, $day, $hour, $minute, $second = 0 |
Method added | 1.0.0 | $year, $month, $day, $hour, $minute, $second |
Carbon::setTimeFromTimeString
string $time
returns Carbon
Set the time by time string.
Prototype changed | 3.0.0 | string $time |
Method added | 1.21.0 | $time |
Carbon::timezone
DateTimeZone|string|int $value
returns Carbon
@alias setTimezone
Prototype changed | 3.0.0 | DateTimeZone|string|int $value |
Method added | 1.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 changed | 3.0.0 | DateTimeZone|string|int|null $value = null |
Prototype changed | 2.0.0 | $value = null |
Method added | 1.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 changed | 3.0.0 | DateTimeZone|string $value |
Method added | 2.0.0 | $value |
Carbon::utc
no arguments
returns Carbon
Set the instance's timezone to UTC.
Method added | 2.0.0 | no arguments |
Carbon::setDateFrom
DateTimeInterface|string $date
returns Carbon
Set the year, month, and date for this instance to that of the passed instance.
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Prototype changed | 2.0.0 | $date = null |
Method added | 1.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 changed | 3.0.0 | DateTimeInterface|string $date |
Prototype changed | 2.0.0 | $date = null |
Method added | 1.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 changed | 3.0.0 | DateTimeInterface|string $date |
Method added | 2.0.0 | $date = null |
Carbon::getDays
no arguments
returns array
Get the days of the week.
Method added | 1.23.0 | no arguments |
Carbon::getWeekStartsAt
?string $locale = null
returns int
Get the first day of week.
Prototype changed | 3.0.0 | ?string $locale = null |
Method added | 1.20.0 | no arguments |
Carbon::getWeekEndsAt
?string $locale = null
returns int
Get the last day of week.
Prototype changed | 3.0.0 | ?string $locale = null |
Method added | 1.20.0 | no arguments |
Carbon::getWeekendDays
no arguments
returns array
Get weekend days
Method added | 1.20.0 | no 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()) ...
$count = 5;
while ($someDate->isDayOff() || ($count-- > 0)) {
$someDate->addDay();
}
Prototype changed | 3.0.0 | array $days |
Method added | 1.20.0 | $days |
Carbon::hasRelativeKeywords
?string $time
returns bool
Determine if a time string will produce a relative date.
Prototype changed | 3.0.0 | ?string $time |
Method added | 1.4.0 | $time |
Carbon::getIsoUnits
no arguments
returns array
Returns list of locale units for ISO formatting.
Method added | 2.0.0 | no 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 added | 2.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 added | 2.0.0 | string $key, ?string $period = null |
Carbon::meridiem
bool $isLower = false
returns string
Return the meridiem of the current time in the current locale.
Method added | 2.14.0 | bool $isLower = false |
Carbon::getAltNumber
string $key
returns string
Returns the alternative number for a given date property if available in the current locale.
Method added | 2.14.0 | string $key |
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 changed | 3.0.0 | string $separator = ':' |
Method added | 2.0.0 | $separator = ':' |
Carbon::setUnit
string $unit, Carbon\Month|int|float|null $value = null
returns Carbon
Set specified unit to new given value.
Prototype changed | 3.0.0 | string $unit, Carbon\Month|int|float|null $value = null |
Method added | 2.0.0 | $unit, $value = null |
Carbon::singularUnit
string $unit
returns string
Returns standardized singular of a given singular/plural unit name (in English).
Method added | 2.0.0 | string $unit |
Carbon::pluralUnit
string $unit
returns string
Returns standardized plural of a given singular/plural unit name (in English).
Method added | 2.0.0 | string $unit |
Carbon::sleep
int|float $seconds
Method added | 3.0.0 | int|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 added | 1.0.0 | no 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 added | 1.0.0 | no 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 added | 1.0.0 | no 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 added | 1.0.0 | no 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 added | 1.22.0 | no 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 added | 1.22.0 | no 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 added | 1.7.0 | no 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 added | 1.7.0 | no 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 added | 1.7.0 | no 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 added | 1.7.0 | no 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 added | 1.7.0 | no 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 added | 1.7.0 | no 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 added | 1.39.0 | no 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 added | 1.39.0 | no 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 changed | 3.0.0 | Carbon\WeekDay|int|null $weekStartsAt = null |
Prototype changed | 2.0.0 | $weekStartsAt = null |
Method added | 1.3.0 | no 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 changed | 3.0.0 | Carbon\WeekDay|int|null $weekEndsAt = null |
Prototype changed | 2.0.0 | $weekEndsAt = null |
Method added | 1.3.0 | no 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 added | 1.24.0 | no 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 added | 1.24.0 | no 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 added | 1.24.0 | no 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 added | 1.24.0 | no 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 added | 1.33.0 | no 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 added | 1.33.0 | no arguments |
Carbon::startOfMillisecond
no arguments
returns Carbon
Modify to start of current millisecond, microseconds such as 12345 become 123000
Examples:
echo Carbon::parse('2018-07-25 12:45:16.334455')
->startOfSecond()
->format('H:i:s.u');
Method added | 3.8.0 | no arguments |
Carbon::endOfMillisecond
no arguments
returns Carbon
Modify to end of current millisecond, microseconds such as 12345 become 123999
Examples:
echo Carbon::parse('2018-07-25 12:45:16.334455')
->endOfSecond()
->format('H:i:s.u');
Method added | 3.8.0 | no arguments |
Carbon::startOf
Carbon\Unit|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(Unit::Month)
->endOf(Unit::Week, Carbon::FRIDAY);
Prototype changed | 3.8.0 | Carbon\Unit|string $unit, mixed $params |
Prototype changed | 3.0.0 | string $unit, mixed $params |
Method added | 2.0.0 | $unit, $params |
Carbon::endOf
Carbon\Unit|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(Unit::Month)
->endOf(Unit::Week, Carbon::FRIDAY);
Prototype changed | 3.8.0 | Carbon\Unit|string $unit, mixed $params |
Prototype changed | 3.0.0 | string $unit, mixed $params |
Method added | 2.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');
Carbon::parse('2018-07-25 12:45:16')->eq(Carbon::parse('2018-07-25 12:45:16'));
Carbon::parse('2018-07-25 12:45:16')->eq('2018-07-25 12:45:17');
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Prototype changed | 1.24.0 | $date |
Prototype changed | 1.23.0 | self $date |
Method added | 1.0.0 | Carbon\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');
Carbon::parse('2018-07-25 12:45:16')->equalTo(Carbon::parse('2018-07-25 12:45:16'));
Carbon::parse('2018-07-25 12:45:16')->equalTo('2018-07-25 12:45:17');
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Prototype changed | 1.24.0 | $date |
Prototype changed | 1.23.0 | self $date |
Method added | 1.22.0 | Carbon\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');
Carbon::parse('2018-07-25 12:45:16')->ne(Carbon::parse('2018-07-25 12:45:16'));
Carbon::parse('2018-07-25 12:45:16')->ne('2018-07-25 12:45:17');
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Prototype changed | 1.24.0 | $date |
Prototype changed | 1.23.0 | self $date |
Method added | 1.0.0 | Carbon\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');
Carbon::parse('2018-07-25 12:45:16')->notEqualTo(Carbon::parse('2018-07-25 12:45:16'));
Carbon::parse('2018-07-25 12:45:16')->notEqualTo('2018-07-25 12:45:17');
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Prototype changed | 1.24.0 | $date |
Prototype changed | 1.23.0 | self $date |
Method added | 1.22.0 | Carbon\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');
Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:16');
Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:17');
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Prototype changed | 1.24.0 | $date |
Prototype changed | 1.23.0 | self $date |
Method added | 1.0.0 | Carbon\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');
Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:16');
Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:17');
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Prototype changed | 1.24.0 | $date |
Prototype changed | 1.23.0 | self $date |
Method added | 1.22.0 | Carbon\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');
Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:16');
Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:17');
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Method added | 1.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');
Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:16');
Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:17');
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Prototype changed | 1.24.0 | $date |
Prototype changed | 1.23.0 | self $date |
Method added | 1.0.0 | Carbon\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');
Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:16');
Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:17');
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Prototype changed | 1.24.0 | $date |
Prototype changed | 1.23.0 | self $date |
Method added | 1.22.0 | Carbon\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');
Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:16');
Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:17');
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Prototype changed | 1.24.0 | $date |
Prototype changed | 1.23.0 | self $date |
Method added | 1.0.0 | Carbon\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');
Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:16');
Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:17');
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Prototype changed | 1.24.0 | $date |
Prototype changed | 1.23.0 | self $date |
Method added | 1.22.0 | Carbon\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');
Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:16');
Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:17');
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Method added | 1.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');
Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:16');
Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:17');
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Prototype changed | 1.24.0 | $date |
Prototype changed | 1.23.0 | self $date |
Method added | 1.0.0 | Carbon\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');
Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:16');
Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:17');
Prototype changed | 3.0.0 | DateTimeInterface|string $date |
Prototype changed | 1.24.0 | $date |
Prototype changed | 1.23.0 | self $date |
Method added | 1.22.0 | Carbon\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');
Carbon::parse('2018-07-25')->between('2018-08-01', '2018-08-20');
Carbon::parse('2018-07-25')->between('2018-07-25', '2018-08-01');
Carbon::parse('2018-07-25')->between('2018-07-25', '2018-08-01', false);
Prototype changed | 3.0.0 | DateTimeInterface|string $date1, DateTimeInterface|string $date2, bool $equal = true |
Prototype changed | 1.24.0 | $date1, $date2, $equal = true |
Prototype changed | 1.23.0 | self $dt1, self $dt2, $equal = true |
Method added | 1.3.0 | Carbon\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');
Carbon::parse('2018-07-25')->betweenIncluded('2018-08-01', '2018-08-20');
Carbon::parse('2018-07-25')->betweenIncluded('2018-07-25', '2018-08-01');
Prototype changed | 3.0.0 | DateTimeInterface|string $date1, DateTimeInterface|string $date2 |
Method added | 2.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');
Carbon::parse('2018-07-25')->betweenExcluded('2018-08-01', '2018-08-20');
Carbon::parse('2018-07-25')->betweenExcluded('2018-07-25', '2018-08-01');
Prototype changed | 3.0.0 | DateTimeInterface|string $date1, DateTimeInterface|string $date2 |
Method added | 2.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');
Carbon::parse('2018-07-25')->isBetween('2018-08-01', '2018-08-20');
Carbon::parse('2018-07-25')->isBetween('2018-07-25', '2018-08-01');
Carbon::parse('2018-07-25')->isBetween('2018-07-25', '2018-08-01', false);
Prototype changed | 3.0.0 | DateTimeInterface|string $date1, DateTimeInterface|string $date2, bool $equal = true |
Method added | 1.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();
Carbon::parse('2019-07-15')->isWeekday();
Method added | 1.0.0 | no arguments |
Carbon::isWeekend
no arguments
returns bool
Determines if the instance is a weekend day.
Examples:
Carbon::parse('2019-07-14')->isWeekend();
Carbon::parse('2019-07-15')->isWeekend();
Method added | 1.0.0 | no arguments |
Carbon::isYesterday
no arguments
returns bool
Determines if the instance is yesterday.
Examples:
Carbon::yesterday()->isYesterday();
Carbon::tomorrow()->isYesterday();
Method added | 1.0.0 | no arguments |
Carbon::isToday
no arguments
returns bool
Determines if the instance is today.
Examples:
Carbon::today()->isToday();
Carbon::tomorrow()->isToday();
Method added | 1.0.0 | no arguments |
Carbon::isTomorrow
no arguments
returns bool
Determines if the instance is tomorrow.
Examples:
Carbon::tomorrow()->isTomorrow();
Carbon::yesterday()->isTomorrow();
Method added | 1.0.0 | no 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();
Carbon::now()->subHours(5)->isFuture();
Method added | 1.0.0 | no 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();
Carbon::now()->addHours(5)->isPast();
Method added | 1.0.0 | no arguments |
Carbon::isLeapYear
no arguments
returns bool
Determines if the instance is a leap year.
Examples:
Carbon::parse('2020-01-01')->isLeapYear();
Carbon::parse('2019-01-01')->isLeapYear();
Method added | 1.0.0 | no 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();
Carbon::create(2016)->isLongYear();
Method added | 1.22.0 | no 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();
Carbon::parse('2016-01-01')->isLongIsoYear();
Carbon::parse('2016-01-03')->isLongIsoYear();
Carbon::parse('2019-12-29')->isLongIsoYear();
Carbon::parse('2019-12-30')->isLongIsoYear();
Method added | 2.65.0 | no 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'));
Carbon::parse('2019-06-13')->isSameAs('Y-d', Carbon::parse('2019-06-14'));
Prototype changed | 3.0.0 | string $format, DateTimeInterface|string $date |
Prototype changed | 1.23.0 | $format, $date = null |
Method added | 1.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'));
Carbon::parse('2018-12-13')->isSameUnit('year', Carbon::parse('2019-12-25'));
Prototype changed | 3.0.0 | string $unit, DateTimeInterface|string $date |
Method added | 2.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');
Carbon::now()->subHours(2)->isCurrentUnit('hour');
Prototype changed | 3.0.0 | string $unit |
Method added | 2.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'));
Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2019-04-01'));
Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2018-03-01'));
Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2018-03-01'), false);
Prototype changed | 3.0.0 | DateTimeInterface|string $date, bool $ofSameYear = true |
Prototype changed | 2.0.0 | $date = null, $ofSameYear = true |
Prototype changed | 1.29.2 | $date = null, $ofSameYear = null |
Method added | 1.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'));
Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2019-02-01'));
Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2018-01-01'));
Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2018-01-01'), false);
Prototype changed | 3.0.0 | DateTimeInterface|string $date, bool $ofSameYear = true |
Prototype changed | 2.0.0 | $date = null, $ofSameYear = true |
Prototype changed | 1.29.2 | $date = null, $ofSameYear = null |
Prototype changed | 1.23.0 | $date = null, $ofSameYear = false |
Method added | 1.22.0 | ?Carbon\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);
Carbon::parse('2019-07-17')->isDayOfWeek(Carbon::FRIDAY);
Carbon::parse('2019-07-17')->isDayOfWeek('Wednesday');
Carbon::parse('2019-07-17')->isDayOfWeek('Friday');
Method added | 1.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();
Carbon::now()->subYears(5)->subDay()->isBirthday();
Carbon::parse('2019-06-05')->isBirthday(Carbon::parse('2001-06-05'));
Carbon::parse('2019-06-05')->isBirthday(Carbon::parse('2001-06-06'));
Prototype changed | 3.0.0 | DateTimeInterface|string|null $date = null |
Prototype changed | 1.23.0 | $date = null |
Prototype changed | 1.21.0 | ?Carbon\Carbon $date = null |
Method added | 1.14.0 | Carbon\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();
Carbon::parse('2019-03-28')->isLastOfMonth();
Carbon::parse('2019-03-30')->isLastOfMonth();
Carbon::parse('2019-03-31')->isLastOfMonth();
Carbon::parse('2019-04-30')->isLastOfMonth();
Method added | 1.24.0 | no arguments |
Carbon::isStartOfUnit
Carbon\Unit $unit, Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, mixed $params
returns bool
Check if the instance is start of a given unit (tolerating a given interval).
Examples:
Carbon::parse('2019-02-28 20:13:00')->isStartOfUnit(Unit::Hour, '15 minutes');
Method added | 3.8.0 | Carbon\Unit $unit, Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, mixed $params |
Carbon::isEndOfUnit
Carbon\Unit $unit, Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, mixed $params
returns bool
Check if the instance is end of a given unit (tolerating a given interval).
Examples:
Carbon::parse('2019-02-28 20:13:00')->isEndOfUnit(Unit::Hour, '15 minutes');
Method added | 3.8.0 | Carbon\Unit $unit, Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, mixed $params |
Carbon::isStartOfMillisecond
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is start of millisecond (first microsecond by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isEndOfMillisecond
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is end of millisecond (last microsecond by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isStartOfSecond
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is start of second (first microsecond by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isEndOfSecond
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is end of second (last microsecond by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isStartOfMinute
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is start of minute (first microsecond by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isEndOfMinute
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is end of minute (last microsecond by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isStartOfHour
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is start of hour (first microsecond by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isEndOfHour
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is end of hour (last microsecond by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isStartOfDay
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|bool $checkMicroseconds = false, Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Check if the instance is start of day / midnight.
Examples:
Carbon::parse('2019-02-28 00:00:00')->isStartOfDay();
Carbon::parse('2019-02-28 00:00:00.999999')->isStartOfDay();
Carbon::parse('2019-02-28 00:00:01')->isStartOfDay();
Carbon::parse('2019-02-28 00:00:00.000000')->isStartOfDay(true);
Carbon::parse('2019-02-28 00:00:00.000012')->isStartOfDay(true);
Prototype changed | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|bool $checkMicroseconds = false, Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Prototype changed | 3.0.0 | bool $checkMicroseconds = false |
Method added | 1.28.0 | $checkMicroseconds = false |
Carbon::isEndOfDay
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|bool $checkMicroseconds = false, Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Check if the instance is end of day.
Examples:
Carbon::parse('2019-02-28 23:59:59.999999')->isEndOfDay();
Carbon::parse('2019-02-28 23:59:59.123456')->isEndOfDay();
Carbon::parse('2019-02-28 23:59:59')->isEndOfDay();
Carbon::parse('2019-02-28 23:59:58.999999')->isEndOfDay();
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);
Prototype changed | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|bool $checkMicroseconds = false, Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Prototype changed | 3.0.0 | bool $checkMicroseconds = false |
Method added | 1.28.0 | $checkMicroseconds = false |
Carbon::isStartOfWeek
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, Carbon\WeekDay|int|null $weekStartsAt = null
returns bool
Determines if the instance is start of week (first day by default but interval can be customized).
Examples:
Carbon::parse('2024-08-31')->startOfWeek()->isStartOfWeek();
Carbon::parse('2024-08-31')->isStartOfWeek();
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, Carbon\WeekDay|int|null $weekStartsAt = null |
Carbon::isEndOfWeek
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, Carbon\WeekDay|int|null $weekEndsAt = null
returns bool
Determines if the instance is end of week (last day by default but interval can be customized).
Examples:
Carbon::parse('2024-08-31')->endOfWeek()->isEndOfWeek();
Carbon::parse('2024-08-31')->isEndOfWeek();
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, Carbon\WeekDay|int|null $weekEndsAt = null |
Carbon::isStartOfMonth
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is start of month (first day by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isEndOfMonth
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is end of month (last day by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isStartOfQuarter
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is start of quarter (first day by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isEndOfQuarter
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is end of quarter (last day by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isStartOfYear
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is start of year (first day by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isEndOfYear
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is end of year (last day by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isStartOfDecade
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is start of decade (first day by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isEndOfDecade
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is end of decade (last day by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isStartOfCentury
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is start of century (first day by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isEndOfCentury
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is end of century (last day by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isStartOfMillennium
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is start of millennium (first day by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
Carbon::isEndOfMillennium
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
returns bool
Determines if the instance is end of millennium (last day by default but interval can be customized).
Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null |
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();
Carbon::parse('2019-02-28 00:00:00.999999')->isMidnight();
Carbon::parse('2019-02-28 00:00:01')->isMidnight();
Method added | 1.28.0 | no arguments |
Carbon::isMidday
no arguments
returns bool
Check if the instance is midday.
Examples:
Carbon::parse('2019-02-28 11:59:59.999999')->isMidday();
Carbon::parse('2019-02-28 12:00:00')->isMidday();
Carbon::parse('2019-02-28 12:00:00.999999')->isMidday();
Carbon::parse('2019-02-28 12:00:01')->isMidday();
Method added | 1.28.0 | no arguments |
Carbon::is
Carbon\WeekDay|Carbon\Month|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'));
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2018'));
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019-06'));
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('06-02'));
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019-06-02'));
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('Sunday'));
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('June'));
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23'));
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23:45'));
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23:00'));
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12h'));
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 15:23:45')->is('3pm'));
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 15:23:45')->is('3am'));
Prototype changed | 3.6.0 | Carbon\WeekDay|Carbon\Month|string $tester |
Method added | 2.20.0 | string $tester |
Carbon::isStartOfTime
no arguments
returns bool
Returns true if the date was created using CarbonImmutable::startOfTime()
Method added | 2.48.0 | no arguments |
Carbon::isEndOfTime
no arguments
returns bool
Returns true if the date was created using CarbonImmutable::endOfTime()
Method added | 2.48.0 | no arguments |
Carbon::__toString
no arguments
returns string
Format the instance as a string using the set format
Examples:
echo Carbon::now();
Method added | 1.0.0 | no arguments |
Carbon::toDateString
no arguments
returns string
Format the instance as date
Examples:
echo Carbon::now()->toDateString();
Method added | 1.0.0 | no arguments |
Carbon::toTimeString
string $unitPrecision = 'second'
returns string
Format the instance as time
Examples:
echo Carbon::now()->toTimeString();
Prototype changed | 3.0.0 | string $unitPrecision = 'second' |
Prototype changed | 2.26.0 | $unitPrecision = 'second' |
Method added | 1.0.0 | no arguments |
Carbon::toDateTimeString
string $unitPrecision = 'second'
returns string
Format the instance as date and time
Examples:
echo Carbon::now()->toDateTimeString();
Prototype changed | 3.0.0 | string $unitPrecision = 'second' |
Prototype changed | 2.26.0 | $unitPrecision = 'second' |
Method added | 1.0.0 | no arguments |
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');
Prototype changed | 3.0.0 | string $unitPrecision = 'second' |
Prototype changed | 2.26.0 | $unitPrecision = 'second' |
Method added | 1.39.0 | no arguments |
Carbon::toDayDateTimeString
no arguments
returns string
Format the instance with day, date and time
Examples:
echo Carbon::now()->toDayDateTimeString();
Method added | 1.0.0 | no arguments |
Carbon::toAtomString
no arguments
returns string
Format the instance as ATOM
Examples:
echo Carbon::now()->toAtomString();
Method added | 1.13.0 | no arguments |
Carbon::toCookieString
no arguments
returns string
Format the instance as COOKIE
Examples:
echo Carbon::now()->toCookieString();
Method added | 1.13.0 | no arguments |
Carbon::toIso8601String
no arguments
returns string
Format the instance as ISO8601
Examples:
echo Carbon::now()->toIso8601String();
Method added | 1.13.0 | no arguments |
Carbon::toRfc822String
no arguments
returns string
Format the instance as RFC822
Examples:
echo Carbon::now()->toRfc822String();
Method added | 1.13.0 | no arguments |
Carbon::toIso8601ZuluString
string $unitPrecision = 'second'
returns string
Convert the instance to UTC and return as Zulu ISO8601
Examples:
echo Carbon::now()->toIso8601ZuluString();
Prototype changed | 3.0.0 | string $unitPrecision = 'second' |
Prototype changed | 2.26.0 | $unitPrecision = 'second' |
Method added | 1.24.0 | no arguments |
Carbon::toRfc850String
no arguments
returns string
Format the instance as RFC850
Examples:
echo Carbon::now()->toRfc850String();
Method added | 1.13.0 | no arguments |
Carbon::toRfc1036String
no arguments
returns string
Format the instance as RFC1036
Examples:
echo Carbon::now()->toRfc1036String();
Method added | 1.13.0 | no arguments |
Carbon::toRfc1123String
no arguments
returns string
Format the instance as RFC1123
Examples:
echo Carbon::now()->toRfc1123String();
Method added | 1.13.0 | no arguments |
Carbon::toRfc2822String
no arguments
returns string
Format the instance as RFC2822
Examples:
echo Carbon::now()->toRfc2822String();
Method added | 1.13.0 | no 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 changed | 3.0.0 | bool $extended = false |
Prototype changed | 2.39.0 | $extended = false |
Method added | 1.13.0 | no arguments |
Carbon::toW3cString
no arguments
returns string
Format the instance as W3C
Examples:
echo Carbon::now()->toW3cString();
Method added | 1.13.0 | no arguments |
Carbon::toRfc7231String
no arguments
returns string
Format the instance as RFC7231
Examples:
echo Carbon::now()->toRfc7231String();
Method added | 1.24.0 | no arguments |
Carbon::toArray
no arguments
returns array
Get default array representation.
Examples:
\Carbon\Doc\Generate\var_dump(Carbon::now()->toArray());
Method added | 1.24.0 | no arguments |
Carbon::toObject
no arguments
returns object
Get default object representation.
Examples:
\Carbon\Doc\Generate\var_dump(Carbon::now()->toObject());
Method added | 1.39.0 | no arguments |
Carbon::toString
no arguments
returns string
Returns english human-readable complete date string.
Examples:
echo Carbon::now()->toString();
Method added | 1.39.0 | no 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 changed | 3.0.0 | bool $keepOffset = false |
Method added | 1.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 added | 1.39.0 | no 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 added | 1.39.0 | no 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 added | 2.23.0 | no 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 added | 1.39.0 | no 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 added | 2.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 added | 2.20.0 | $end = null, $interval = null, $unit = null |
Carbon::__clone
no arguments
Update constructedObjectId on cloned.
Method added | 2.29.0 | no arguments |
Carbon::instance
DateTimeInterface $date
returns Carbon
Create a Carbon instance from a DateTime one.
Prototype changed | 3.0.0 | DateTimeInterface $date |
Prototype changed | 1.26.0 | $date |
Method added | 1.0.0 | DateTime $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 changed | 3.0.0 | DateTimeInterface|Carbon\WeekDay|Carbon\Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = null |
Method added | 2.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 changed | 3.0.0 | DateTimeInterface|Carbon\WeekDay|Carbon\Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = null |
Method added | 1.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 changed | 3.0.0 | string $time, ?string $locale = null, DateTimeZone|string|int|null $timezone = null |
Prototype changed | 2.35.0 | $time, $locale = null, $tz = null |
Method added | 2.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 changed | 3.0.0 | DateTimeZone|string|int|null $timezone = null |
Method added | 1.0.0 | $tz = null |
Carbon::today
DateTimeZone|string|int|null $timezone = null
returns Carbon
Create a Carbon instance for today.
Prototype changed | 3.0.0 | DateTimeZone|string|int|null $timezone = null |
Method added | 1.1.0 | $tz = null |
Carbon::tomorrow
DateTimeZone|string|int|null $timezone = null
returns Carbon
Create a Carbon instance for tomorrow.
Prototype changed | 3.0.0 | DateTimeZone|string|int|null $timezone = null |
Method added | 1.1.0 | $tz = null |
Carbon::yesterday
DateTimeZone|string|int|null $timezone = null
returns Carbon
Create a Carbon instance for yesterday.
Prototype changed | 3.0.0 | DateTimeZone|string|int|null $timezone = null |
Method added | 1.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 changed | 3.0.0 | $year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $timezone = null |
Prototype changed | 2.0.0 | $year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null |
Method added | 1.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 changed | 3.0.0 | $year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null |
Method added | 1.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 changed | 3.0.0 | ?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $timezone = null |
Method added | 2.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 changed | 3.0.0 | $year = null, $month = null, $day = null, $timezone = null |
Method added | 1.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 changed | 3.0.0 | $year = null, $month = null, $day = null, $timezone = null |
Method added | 1.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 changed | 3.0.0 | $hour = 0, $minute = 0, $second = 0, $timezone = null |
Prototype changed | 2.0.0 | $hour = 0, $minute = 0, $second = 0, $tz = null |
Method added | 1.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 changed | 3.0.0 | string $time, DateTimeZone|string|int|null $timezone = null |
Method added | 1.25.0 | $time, $tz = null |
Carbon::make
$var, DateTimeZone|string|null $timezone = null
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.
Prototype changed | 3.6.0 | $var, DateTimeZone|string|null $timezone = null |
Method added | 1.28.0 | $var |
Carbon::getClock
no arguments
returns WrapperClock
Method added | 3.0.0 | no 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 added | 3.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 changed | 3.0.0 | $date = null, bool $absolute = false, array $skip = [] |
Prototype changed | 2.64.0 | $date = null, $absolute = true, array $skip = [] |
Prototype changed | 2.0.0 | $date = null, $absolute = true |
Prototype changed | 1.35.0 | $date = null, $absolute = true, $trimMicroseconds = true |
Method added | 1.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 changed | 3.2.0 | Carbon\Unit|string $unit, $date = null, bool $absolute = false, bool $utc = false |
Prototype changed | 3.1.0 | Carbon\Unit|string $unit, $date = null, bool $absolute = false |
Method added | 3.0.0 | string $unit, $date = null, bool $absolute = false |
Carbon::diffInYears
$date = null, bool $absolute = false, bool $utc = false
returns float
Get the difference in years
Prototype changed | 3.2.0 | $date = null, bool $absolute = false, bool $utc = false |
Prototype changed | 3.0.0 | $date = null, bool $absolute = false |
Prototype changed | 1.24.0 | $date = null, $absolute = true |
Prototype changed | 1.23.0 | ?self $date = null, $absolute = true |
Prototype changed | 1.21.0 | ?Carbon\Carbon $date = null, $absolute = true |
Method added | 1.0.0 | Carbon\Carbon $date = null, $absolute = true |
Carbon::diffInQuarters
$date = null, bool $absolute = false, bool $utc = false
returns float
Get the difference in quarters.
Prototype changed | 3.2.0 | $date = null, bool $absolute = false, bool $utc = false |
Prototype changed | 3.0.0 | $date = null, bool $absolute = false |
Method added | 2.31.0 | $date = null, $absolute = true |
Carbon::diffInMonths
$date = null, bool $absolute = false, bool $utc = false
returns float
Get the difference in months.
Prototype changed | 3.2.0 | $date = null, bool $absolute = false, bool $utc = false |
Prototype changed | 3.0.0 | $date = null, bool $absolute = false |
Prototype changed | 1.24.0 | $date = null, $absolute = true |
Prototype changed | 1.23.0 | ?self $date = null, $absolute = true |
Prototype changed | 1.21.0 | ?Carbon\Carbon $date = null, $absolute = true |
Method added | 1.0.0 | Carbon\Carbon $date = null, $absolute = true |
Carbon::diffInWeeks
$date = null, bool $absolute = false, bool $utc = false
returns float
Get the difference in weeks.
Prototype changed | 3.2.0 | $date = null, bool $absolute = false, bool $utc = false |
Prototype changed | 3.0.0 | $date = null, bool $absolute = false |
Prototype changed | 1.24.0 | $date = null, $absolute = true |
Prototype changed | 1.23.0 | ?self $date = null, $absolute = true |
Prototype changed | 1.21.0 | ?Carbon\Carbon $date = null, $absolute = true |
Method added | 1.11.0 | Carbon\Carbon $date = null, $absolute = true |
Carbon::diffInDays
$date = null, bool $absolute = false, bool $utc = false
returns float
Get the difference in days.
Prototype changed | 3.2.0 | $date = null, bool $absolute = false, bool $utc = false |
Prototype changed | 3.0.0 | $date = null, bool $absolute = false |
Prototype changed | 1.24.0 | $date = null, $absolute = true |
Prototype changed | 1.23.0 | ?self $date = null, $absolute = true |
Prototype changed | 1.21.0 | ?Carbon\Carbon $date = null, $absolute = true |
Method added | 1.0.0 | Carbon\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 changed | 3.0.0 | Closure $callback, $date = null, bool $absolute = false |
Prototype changed | 1.24.0 | Closure $callback, $date = null, $absolute = true |
Prototype changed | 1.23.0 | Closure $callback, ?self $date = null, $absolute = true |
Prototype changed | 1.21.0 | Closure $callback, ?Carbon\Carbon $date = null, $absolute = true |
Method added | 1.12.0 | Closure $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 changed | 3.0.0 | Closure $callback, $date = null, bool $absolute = false |
Prototype changed | 1.24.0 | Closure $callback, $date = null, $absolute = true |
Prototype changed | 1.23.0 | Closure $callback, ?self $date = null, $absolute = true |
Prototype changed | 1.21.0 | Closure $callback, ?Carbon\Carbon $date = null, $absolute = true |
Method added | 1.18.0 | Closure $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 changed | 3.0.0 | Carbon\CarbonInterval $ci, Closure $callback, $date = null, bool $absolute = false |
Prototype changed | 1.24.0 | Carbon\CarbonInterval $ci, Closure $callback, $date = null, $absolute = true |
Prototype changed | 1.23.0 | Carbon\CarbonInterval $ci, Closure $callback, ?self $date = null, $absolute = true |
Prototype changed | 1.21.0 | Carbon\CarbonInterval $ci, Closure $callback, ?Carbon\Carbon $date = null, $absolute = true |
Method added | 1.18.0 | Carbon\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 changed | 3.0.0 | $date = null, bool $absolute = false |
Prototype changed | 1.24.0 | $date = null, $absolute = true |
Prototype changed | 1.23.0 | ?self $date = null, $absolute = true |
Prototype changed | 1.21.0 | ?Carbon\Carbon $date = null, $absolute = true |
Method added | 1.12.0 | Carbon\Carbon $date = null, $absolute = true |
Carbon::diffInWeekendDays
$date = null, bool $absolute = false
returns int
Get the difference in weekend days using a filter.
Prototype changed | 3.0.0 | $date = null, bool $absolute = false |
Prototype changed | 1.24.0 | $date = null, $absolute = true |
Prototype changed | 1.23.0 | ?self $date = null, $absolute = true |
Prototype changed | 1.21.0 | ?Carbon\Carbon $date = null, $absolute = true |
Method added | 1.12.0 | Carbon\Carbon $date = null, $absolute = true |
Carbon::diffInHours
$date = null, bool $absolute = false
returns float
Get the difference in hours.
Prototype changed | 3.0.0 | $date = null, bool $absolute = false |
Prototype changed | 1.24.0 | $date = null, $absolute = true |
Prototype changed | 1.23.0 | ?self $date = null, $absolute = true |
Prototype changed | 1.21.0 | ?Carbon\Carbon $date = null, $absolute = true |
Method added | 1.0.0 | Carbon\Carbon $date = null, $absolute = true |
Carbon::diffInMinutes
$date = null, bool $absolute = false
returns float
Get the difference in minutes.
Prototype changed | 3.0.0 | $date = null, bool $absolute = false |
Prototype changed | 1.24.0 | $date = null, $absolute = true |
Prototype changed | 1.23.0 | ?self $date = null, $absolute = true |
Prototype changed | 1.21.0 | ?Carbon\Carbon $date = null, $absolute = true |
Method added | 1.0.0 | Carbon\Carbon $date = null, $absolute = true |
Carbon::diffInSeconds
$date = null, bool $absolute = false
returns float
Get the difference in seconds.
Prototype changed | 3.0.0 | $date = null, bool $absolute = false |
Prototype changed | 1.24.0 | $date = null, $absolute = true |
Prototype changed | 1.23.0 | ?self $date = null, $absolute = true |
Prototype changed | 1.21.0 | ?Carbon\Carbon $date = null, $absolute = true |
Method added | 1.0.0 | Carbon\Carbon $date = null, $absolute = true |
Carbon::diffInMicroseconds
$date = null, bool $absolute = false
returns float
Get the difference in microseconds.
Prototype changed | 3.0.0 | $date = null, bool $absolute = false |
Method added | 1.39.0 | $date = null, $absolute = true |
Carbon::diffInMilliseconds
$date = null, bool $absolute = false
returns float
Get the difference in milliseconds.
Prototype changed | 3.0.0 | $date = null, bool $absolute = false |
Method added | 1.39.0 | $date = null, $absolute = true |
Carbon::secondsSinceMidnight
no arguments
returns float
The number of seconds since midnight.
Method added | 1.14.0 | no arguments |
Carbon::secondsUntilEndOfDay
no arguments
returns float
The number of seconds until 23:59:59.
Method added | 1.14.0 | no 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 changed | 2.0.0 | $other = null, $syntax = null, $short = false, $parts = 1, $options = null |
Prototype changed | 1.25.0 | $other = null, $absolute = false, $short = false, $parts = 1 |
Prototype changed | 1.23.0 | ?self $other = null, $absolute = false, $short = false, $parts = 1 |
Prototype changed | 1.22.0 | ?Carbon\Carbon $other = null, $absolute = false, $short = false |
Prototype changed | 1.21.0 | ?Carbon\Carbon $other = null, $absolute = false |
Prototype changed | 1.14.0 | Carbon\Carbon $other = null, $absolute = false |
Method added | 1.0.0 | Carbon\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 changed | 2.0.0 | $other = null, $syntax = null, $short = false, $parts = 1, $options = null |
Method added | 1.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 changed | 2.0.0 | $other = null, $syntax = null, $short = false, $parts = 1, $options = null |
Method added | 1.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 changed | 2.0.0 | $other = null, $syntax = null, $short = false, $parts = 1, $options = null |
Method added | 1.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 changed | 2.0.0 | $other = null, $syntax = null, $short = false, $parts = 1, $options = null |
Method added | 1.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 changed | 2.0.0 | $syntax = null, $short = false, $parts = 1, $options = null |
Method added | 1.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 changed | 2.0.0 | $syntax = null, $short = false, $parts = 1, $options = null |
Method added | 1.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 changed | 2.16.0 | $syntax = null, $short = false, $parts = 1, $options = null |
Method added | 1.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 added | 2.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 added | 2.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 changed | 3.0.1 | string $name, ?callable $macro |
Prototype changed | 3.0.0 | string $name, callable|object $macro |
Method added | 1.26.0 | $name, $macro |
Carbon::resetMacros
no arguments
Remove all macros and generic macros.
Method added | 1.39.0 | no arguments |
Carbon::genericMacro
callable $macro, int $priority = 0
Register a custom macro.
Prototype changed | 3.0.1 | callable $macro, int $priority = 0 |
Prototype changed | 3.0.0 | callable|object $macro, int $priority = 0 |
Method added | 2.1.0 | $macro, $priority = 0 |
Carbon::hasMacro
string $name
returns bool
Checks if macro is registered globally.
Prototype changed | 3.0.0 | string $name |
Method added | 1.26.0 | $name |
Carbon::getMacro
string $name
returns callable
Get the raw callable macro registered globally for a given name.
Prototype changed | 3.0.0 | string $name |
Method added | 2.29.0 | $name |
Carbon::hasLocalMacro
string $name
returns bool
Checks if macro is registered globally or locally.
Prototype changed | 3.0.0 | string $name |
Method added | 2.29.0 | $name |
Carbon::getLocalMacro
string $name
returns callable
Get the raw callable macro registered globally or locally for a given name.
Prototype changed | 3.0.0 | string $name |
Method added | 2.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 changed | 3.0.0 | object|string $mixin |
Method added | 1.26.0 | $mixin |
Carbon::getMidDayAt
no arguments
returns int
get midday/noon hour
Method added | 1.24.0 | no 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
Carbon::midDay
no arguments
returns Carbon
Modify to midday, default to self::$midDayAt
Method added | 1.24.0 | no 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 changed | 2.20.0 | $modifier = null |
Method added | 1.3.0 | $dayOfWeek = null |
Carbon::nextWeekday
no arguments
returns Carbon
Go forward to the next weekday.
Method added | 1.22.0 | no arguments |
Carbon::previousWeekday
no arguments
returns Carbon
Go backward to the previous weekday.
Method added | 1.22.0 | no arguments |
Carbon::nextWeekendDay
no arguments
returns Carbon
Go forward to the next weekend day.
Method added | 1.22.0 | no arguments |
Carbon::previousWeekendDay
no arguments
returns Carbon
Go backward to the previous weekend day.
Method added | 1.22.0 | no 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 changed | 2.20.0 | $modifier = null |
Method added | 1.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 added | 1.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 added | 1.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 added | 1.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 added | 1.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 added | 1.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 added | 1.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 added | 1.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 added | 1.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 added | 1.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 changed | 1.24.0 | $date = null |
Prototype changed | 1.23.0 | ?self $date = null |
Prototype changed | 1.21.0 | ?Carbon\Carbon $date = null |
Method added | 1.7.0 | Carbon\Carbon $date = null |
Carbon::closest
$date1, $date2
returns Carbon
Get the closest date from the instance (second-precision).
Prototype changed | 1.24.0 | $date1, $date2 |
Prototype changed | 1.23.0 | self $dt1, self $dt2 |
Method added | 1.21.0 | Carbon\Carbon $dt1, Carbon\Carbon $dt2 |
Carbon::farthest
$date1, $date2
returns Carbon
Get the farthest date from the instance (second-precision).
Prototype changed | 1.24.0 | $date1, $date2 |
Prototype changed | 1.23.0 | self $dt1, self $dt2 |
Method added | 1.21.0 | Carbon\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 changed | 1.24.0 | $date = null |
Prototype changed | 1.23.0 | ?self $date = null |
Prototype changed | 1.21.0 | ?Carbon\Carbon $date = null |
Method added | 1.8.0 | Carbon\Carbon $date = null |
Carbon::minimum
$date = null
returns Carbon
Get the minimum instance between a given instance (default now) and the current instance.
Prototype changed | 1.24.0 | $date = null |
Prototype changed | 1.23.0 | ?self $date = null |
Method added | 1.22.0 | ?Carbon\Carbon $date = null |
Carbon::max
$date = null
returns Carbon
Get the maximum instance between a given instance (default now) and the current instance.
Prototype changed | 1.24.0 | $date = null |
Prototype changed | 1.23.0 | ?self $date = null |
Prototype changed | 1.21.0 | ?Carbon\Carbon $date = null |
Method added | 1.8.0 | Carbon\Carbon $date = null |
Carbon::maximum
$date = null
returns Carbon
Get the maximum instance between a given instance (default now) and the current instance.
Prototype changed | 1.24.0 | $date = null |
Prototype changed | 1.23.0 | ?self $date = null |
Method added | 1.22.0 | ?Carbon\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 added | 2.20.0 | $modifier |
Carbon::isImmutable
no arguments
returns bool
Returns true if the current class/instance is immutable.
Method added | 2.0.0 | no arguments |
Carbon::toMutable
no arguments
returns Carbon
Return a mutable copy of the instance.
Method added | 2.0.0 | no arguments |
Carbon::toImmutable
no arguments
returns CarbonImmutable
Return a immutable copy of the instance.
Method added | 2.0.0 | no arguments |
Carbon::cast
string $className
returns mixed
Cast the current instance into the given class.
Prototype changed | 2.8.0 | string $className |
Method added | 1.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 added | 2.0.0 | array $settings |
Carbon::getSettings
no arguments
returns array
Returns current local settings.
Method added | 2.3.0 | no arguments |
Carbon::__debugInfo
no arguments
returns array
Show truthy properties on \Carbon\Doc\Generate\var_dump().
Method added | 1.39.0 | no 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 changed | 3.0.0 | bool $strictModeEnabled = true |
Method added | 2.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 added | 2.0.0 | no 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 changed | 3.0.0 | bool $monthsOverflow = true |
Method added | 1.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 added | 1.22.0 | no arguments |
Carbon::shouldOverflowMonths
no arguments
returns bool
Get the month overflow global behavior (can be overridden in specific instances).
Method added | 1.22.0 | no 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 changed | 3.0.0 | bool $yearsOverflow = true |
Method added | 1.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 added | 1.24.0 | no arguments |
Carbon::shouldOverflowYears
no arguments
returns bool
Get the month overflow global behavior (can be overridden in specific instances).
Method added | 1.24.0 | no arguments |
Carbon::hasLocalTranslator
no arguments
returns bool
Return true if the current instance has its own translator.
Method added | 2.29.0 | no arguments |
Carbon::getLocalTranslator
no arguments
returns Symfony\Contracts\Translation\TranslatorInterface
Get the translator of the current instance or the default if none set.
Method added | 2.0.0 | no arguments |
Carbon::setLocalTranslator
Symfony\Contracts\Translation\TranslatorInterface $translator
returns Carbon
Set the translator for the current instance.
Prototype changed | 3.0.0 | Symfony\Contracts\Translation\TranslatorInterface $translator |
Method added | 2.0.0 | Symfony\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 added | 2.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 changed | 2.8.0 | string $key, ?string $locale = null, ?string $default = null, $translator = null |
Method added | 2.0.0 | string $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 changed | 3.0.0 | Symfony\Contracts\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null |
Method added | 2.8.0 | Symfony\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 changed | 3.0.0 | string $key, array $parameters = [], string|int|float|null $number = null, ?Symfony\Contracts\Translation\TranslatorInterface $translator = null, bool $altNumbers = false |
Prototype changed | 2.23.0 | string $key, array $parameters = [], $number = null, ?Symfony\Component\Translation\TranslatorInterface $translator = null, bool $altNumbers = false |
Prototype changed | 2.8.0 | string $key, array $parameters = [], $number = null, ?Symfony\Component\Translation\TranslatorInterface $translator = null |
Method added | 2.0.0 | string $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 added | 2.23.0 | int $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 changed | 3.0.0 | string $timeString, ?string $from = null, ?string $to = null, int $mode = 31 |
Prototype changed | 2.35.0 | $timeString, $from = null, $to = null, $mode = 31 |
Method added | 2.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 changed | 3.0.0 | string $timeString, ?string $to = null |
Method added | 2.16.0 | $timeString, $to = null |
Carbon::locale
?string $locale = null, string $fallbackLocales
returns Carbon|string
Get/set the locale for the current instance.
Prototype changed | 3.0.0 | ?string $locale = null, string $fallbackLocales |
Prototype changed | 2.16.0 | ?string $locale = null, $fallbackLocales |
Method added | 2.0.0 | ?string $locale = null |
Carbon::getLocale
no arguments
returns string
Get the current translator locale.
Method added | 1.18.0 | no 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 changed | 3.0.0 | string $locale |
Method added | 1.18.0 | $locale |
Carbon::setFallbackLocale
string $locale
Set the fallback locale.
Prototype changed | 3.0.0 | string $locale |
Method added | 2.16.0 | $locale |
Carbon::getFallbackLocale
no arguments
returns string
Get the fallback locale.
Method added | 2.16.0 | no 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 changed | 3.0.0 | string $locale, callable $func |
Method added | 1.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 changed | 3.0.0 | string $locale |
Method added | 1.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 changed | 3.0.0 | string $locale |
Method added | 1.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 changed | 3.0.0 | string $locale |
Method added | 1.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 changed | 3.0.0 | string $locale |
Method added | 1.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 added | 1.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 added | 1.31.0 | no 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 added | 2.10.1 | no 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 changed | 3.0.0 | int $humanDiffOptions |
Method added | 1.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 changed | 3.0.0 | int $humanDiffOption |
Method added | 1.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 changed | 3.0.0 | int $humanDiffOption |
Method added | 1.26.0 | $humanDiffOption |
Carbon::getHumanDiffOptions
no arguments
returns int
Return default humanDiff() options (merged flags as integer).
Method added | 1.26.0 | no arguments |
Carbon::setTranslator
Symfony\Contracts\Translation\TranslatorInterface $translator
Set the default translator instance to use.
Prototype changed | 3.0.0 | Symfony\Contracts\Translation\TranslatorInterface $translator |
Method added | 1.18.0 | Symfony\Component\Translation\TranslatorInterface $translator |
Carbon::getTranslator
no arguments
returns Symfony\Contracts\Translation\TranslatorInterface
Initialize the default translator instance if necessary.
Method added | 1.18.0 | no 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 changed | 3.0.0 | string $unit, DateInterval|string|int|float $precision = 1, callable|string $function = 'round' |
Method added | 2.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 changed | 3.0.0 | string $unit, DateInterval|string|int|float $precision = 1 |
Method added | 2.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 changed | 3.0.0 | string $unit, DateInterval|string|int|float $precision = 1 |
Method added | 2.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 changed | 3.0.0 | DateInterval|string|int|float $precision = 1, callable|string $function = 'round' |
Method added | 2.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 changed | 3.0.0 | DateInterval|string|int|float $precision = 1 |
Method added | 2.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 changed | 3.0.0 | DateInterval|string|int|float $precision = 1 |
Method added | 2.0.0 | $precision = 1 |
Carbon::roundWeek
Carbon\WeekDay|int|null $weekStartsAt = null
returns Carbon
Round the current instance week.
Prototype changed | 3.0.0 | Carbon\WeekDay|int|null $weekStartsAt = null |
Method added | 2.0.0 | $weekStartsAt = null |
Carbon::floorWeek
Carbon\WeekDay|int|null $weekStartsAt = null
returns Carbon
Truncate the current instance week.
Prototype changed | 3.0.0 | Carbon\WeekDay|int|null $weekStartsAt = null |
Method added | 2.0.0 | $weekStartsAt = null |
Carbon::ceilWeek
Carbon\WeekDay|int|null $weekStartsAt = null
returns Carbon
Ceil the current instance week.
Prototype changed | 3.0.0 | Carbon\WeekDay|int|null $weekStartsAt = null |
Method added | 2.0.0 | $weekStartsAt = null |
Carbon::serialize
no arguments
returns string
Return a serialized string of the instance.
Method added | 1.22.0 | no arguments |
Carbon::fromSerialized
$value
returns Carbon
Create an instance from a serialized string.
Carbon::__sleep
no arguments
returns array
Returns the list of properties to dump on serialize() called on.
Only used by PHP < 7.4.
Method added | 2.0.0 | no arguments |
Carbon::jsonSerialize
no arguments
returns mixed
Prepare the object for JSON serialization.
Method added | 1.26.0 | no 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 changed | 3.0.0 | callable|string|null $format |
Method added | 1.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 added | 2.29.0 | no 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 changed | 3.0.0 | mixed $testNow = null |
Prototype changed | 1.22.0 | $testNow = null |
Prototype changed | 1.21.0 | ?Carbon\Carbon $testNow = null |
Method added | 1.3.0 | Carbon\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 changed | 3.0.0 | $testNow = null, $timezone = null |
Method added | 2.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 changed | 3.0.0 | mixed $testNow, callable $callback |
Prototype changed | 2.67.0 | $testNow, $callback |
Method added | 2.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 added | 1.3.0 | no 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 added | 1.3.0 | no 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 changed | 3.0.0 | string|int|float $timestamp, DateTimeZone|string|int|null $timezone = null |
Method added | 1.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 changed | 3.0.0 | string|int|float $timestamp |
Method added | 1.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 added | 2.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 changed | 3.0.0 | string|int|float $timestamp, DateTimeZone|string|int|null $timezone = null |
Method added | 1.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 changed | 3.0.0 | string|int|float $timestamp |
Prototype changed | 2.41.0 | $unixTimestamp |
Method added | 1.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 added | 2.0.0 | $precision = 6 |
Carbon::valueOf
no arguments
returns float
Returns the milliseconds timestamps used amongst other by Date javascript objects.
Method added | 2.0.0 | no arguments |
Carbon::getTimestampMs
no arguments
returns int
Returns the timestamp with millisecond precision.
Method added | 2.51.0 | no arguments |
Carbon::unix
no arguments
returns int
@alias getTimestamp
Returns the UNIX timestamp for the current date.
Method added | 2.0.0 | no 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 changed | 3.0.0 | string $unit, $value = 1 |
Method added | 2.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 added | 3.2.0 | string $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 added | 2.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 added | 3.2.0 | $unit, $value = 1 |
Carbon::isModifiableUnit
$unit
returns bool
Returns true if a property can be changed via setter.
Carbon::rawAdd
DateInterval $interval
returns Carbon
Call native PHP DateTime/DateTimeImmutable add() method.
Method added | 2.36.0 | DateInterval $interval |
Carbon::addUnit
Carbon\Unit|string $unit, $value = 1, ?bool $overflow = null
returns Carbon
Add given units to the current instance.
Prototype changed | 3.1.0 | Carbon\Unit|string $unit, $value = 1, ?bool $overflow = null |
Prototype changed | 3.0.0 | string $unit, $value = 1, ?bool $overflow = null |
Method added | 2.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 changed | 3.1.0 | Carbon\Unit|string $unit, $value = 1, ?bool $overflow = null |
Prototype changed | 3.0.0 | string $unit, $value = 1, ?bool $overflow = null |
Method added | 2.0.0 | $unit, $value = 1, $overflow = null |
Carbon::rawSub
DateInterval $interval
returns Carbon
Call native PHP DateTime/DateTimeImmutable sub() method.
Method added | 2.36.0 | DateInterval $interval |
Carbon::subtract
$unit, $value = 1, ?bool $overflow = null
returns Carbon
Subtract given units or interval to the current instance.
Prototype changed | 3.0.0 | $unit, $value = 1, ?bool $overflow = null |
Method added | 2.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 added | 2.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 added | 2.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 added | 2.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 added | 2.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 added | 2.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 added | 2.0.0 | $week = null, $dayOfWeek = null, $dayOfYear = null |
Carbon::normalizeDay
no arguments
returns string
Returns day English name in lower case.
Carbon::convertOpeningHours
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
no arguments
Carbon::setOpeningHours
no arguments
returns $this|null
Set the opening hours for the class/instance.
Carbon::resetOpeningHours
no arguments
returns $this|null
Reset the opening hours for the class/instance.
Carbon::getOpeningHours
no arguments
returns Spatie\OpeningHours\OpeningHours
Get the opening hours of the class/instance.
Carbon::safeCallOnOpeningHours
no arguments
returns mixed
Call a method on the OpeningHours of the current instance.
Carbon::getCalleeAsMethod
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
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
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
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Add a given number of business days to the current date.
Carbon::addBusinessDay
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Add a given number of business days to the current date.
Carbon::subBusinessDays
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Add a given number of business days to the current date.
Carbon::subtractBusinessDays
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Add a given number of business days to the current date.
Carbon::subBusinessDay
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Add a given number of business days to the current date.
Carbon::subtractBusinessDay
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Add a given number of business days to the current date.
Carbon::diffInBusinessDays
no arguments
returns int
Returns the difference between 2 dates in business days.
Carbon::getBusinessDaysInMonth
no arguments
returns int
Get the number of business days in the current month.
Carbon::getMonthBusinessDays
no arguments
returns array
Get list of date objects for each business day in the current month.
Carbon::setBusinessDayChecker
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
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
no arguments
returns CarbonInterface|Carbon|CarbonImmutable
Sets the date to the next business day (neither a weekend day nor a holiday).
Carbon::currentOrNextBusinessDay
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
no arguments
returns CarbonInterface|Carbon|CarbonImmutable
Sets the date to the next business day (neither a weekend day nor a holiday).
Carbon::currentOrPreviousBusinessDay
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
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
no arguments
returns string|null
Get the selected zone for observed holidays.
Carbon::setHolidayObserveStatus
no arguments
returns $this|null
Set a holiday as observed/unobserved in the selected zone.
Carbon::getObserveHolidayMethod
no arguments
returns $this|null
Set a holiday as observed/unobserved in the selected zone (can take array of holidays).
Carbon::observeHoliday
no arguments
returns $this|null
Set a holiday as observed/unobserved in the selected zone (can take array of holidays).
Carbon::unobserveHoliday
no arguments
returns $this|null
Set a holiday as observed/unobserved in the selected zone (can take array of holidays).
Carbon::observeHolidays
no arguments
returns $this|null
Set a holiday as observed/unobserved in the selected zone (can take array of holidays).
Carbon::unobserveHolidays
no arguments
returns $this|null
Set a holiday as observed/unobserved in the selected zone (can take array of holidays).
Carbon::observeAllHolidays
no arguments
returns $this|null
Set a holiday as observed/unobserved in the selected zone (can take array of holidays).
Carbon::unobserveAllHolidays
no arguments
returns $this|null
Set a holiday as observed/unobserved in the selected zone (can take array of holidays).
Carbon::checkObservedHoliday
no arguments
returns bool
Check if a given holiday ID is observed in the selected zone.
Carbon::isObservedHoliday
no arguments
returns bool
Checks the date to see if it is a holiday observed in the selected zone.
Carbon::setHolidayGetter
no arguments
returns $this|null
Set the strategy to get the holiday ID from a date object.
Carbon::getDBDayId
no arguments
returns string|false
Get the identifier of the current holiday or false if it's not a holiday.
Carbon::getHolidayId
no arguments
returns string|false
Get the identifier of the current holiday or false if it's not a holiday.
Carbon::isHoliday
no arguments
returns bool
Checks the date to see if it is a holiday.
Carbon::getHolidayNamesDictionary
no arguments
returns array
Get the holidays in the given language.
Carbon::getHolidayName
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
no arguments
returns array
Get the holidays dates for a given year (current year if no parameter given).
Carbon::getYearHolidaysNextFunction
no arguments
returns callable
Get a next() callback to call to iterate over holidays of a year.
Carbon::standardizeHolidaysRegion
no arguments
returns string
Return a standardized region name.
Carbon::getHolidaysAvailableRegions
no arguments
returns array
Get the current holidays region.
Carbon::setHolidaysRegion
no arguments
Set the holidays region (see src/Cmixin/Holidays for examples).
Carbon::getHolidaysRegion
no arguments
returns null|string
Get the current holidays region.
Carbon::getBDDaysList
no arguments
returns array
Get the holidays for the current region selected.
Carbon::getHolidays
no arguments
returns array
Get the holidays for the current region selected.
Carbon::setHolidays
no arguments
Set the holidays list.
Carbon::resetHolidays
no arguments
Reset the holidays list.
Carbon::initializeHolidaysRegion
no arguments
Carbon::pushToBDList
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|null
Push a day into a given list list of a region.
Carbon::pushHoliday
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|null
Push a holiday to the holidays list of a region.
Carbon::pushWorkday
no arguments
returns Carbon|CarbonImmutable|CarbonInterface|null
Push a workday to the workdays list of a region.
Carbon::setHolidayName
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
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::unpackHoliday
no arguments
returns array
Unpack a holiday array definition.
Carbon::checkHoliday
no arguments
returns array
Check a holiday definition and unpack it if it's an array.
Carbon::addHolidays
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
no arguments
returns bool
Return true if the given value is a DateTime or DateTimeInterface.
Carbon::swapDateTimeParam
no arguments
returns array
Store a first variable as Carbon instance into the second variable if the first one is a date.
Carbon::skipMissingCalendarExtensionException
no arguments
@codeCoverageIgnore
Carbon::shouldRaiseMissingCalendarExtensionException
no arguments
returns bool
Carbon::getHolidayDataById
no arguments
returns array
Get stored data set for the a given holiday ID.
Carbon::setHolidayDataById
no arguments
returns $this|null
Set stored data set for the a given holiday ID.
Carbon::getHolidayData
no arguments
returns array
Get stored data set for the current holiday or null if it's not a holiday.
Carbon::setHolidayData
no arguments
returns $this|null
Set stored data set for the current holiday, does nothing if it's not a holiday.
Carbon::setMaxIteration
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
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
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
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
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
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Add the given interval taking into account only open time.
Carbon::subOpenTime
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Subtract the given interval taking into account only open time.
Carbon::addClosedTime
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Add the given interval taking into account only closed time.
Carbon::subClosedTime
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Subtract the given interval taking into account only closed time.
Carbon::addOpenMinutes
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Add the given number of minutes taking into account only open time.
Carbon::subOpenMinutes
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Subtract the given number of minutes taking into account only open time.
Carbon::addClosedMinutes
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Add the given number of minutes taking into account only closed time.
Carbon::subClosedMinutes
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Subtract the given number of minutes taking into account only closed time.
Carbon::addOpenHours
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Add the given number of hours taking into account only open time.
Carbon::subOpenHours
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Subtract the given number of hours taking into account only open time.
Carbon::addClosedHours
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Add the given number of hours taking into account only closed time.
Carbon::subClosedHours
no arguments
returns Carbon|CarbonImmutable|CarbonInterface
Subtract the given number of hours taking into account only closed time.
Carbon::closedOrNextOpenExcludingHolidays
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
no arguments
returns CarbonInterval
Return an interval with open/closed business time between the current date and an other
given date.
Carbon::diffInBusinessSeconds
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
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
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
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
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
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
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
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
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
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
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
no arguments
returns bool
Returns true if the business is open on a given day according to current opening hours.
Carbon::isClosedOn
no arguments
returns bool
Returns true if the business is open on a given day according to current opening hours.
Carbon::isOpen
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
no arguments
returns Spatie\OpeningHours\OpeningHoursForDay
Get OpeningHoursForDay instance of the current instance or class.
Carbon::getCurrentOpenTimeRanges
no arguments
returns Spatie\OpeningHours\TimeRange[]
Get open time ranges as array of TimeRange instances that matches the current date and time.
Carbon::getCurrentOpenTimeRange
no arguments
returns Spatie\OpeningHours\TimeRange|bool
Get current open time range as TimeRange instance or false if closed.
Carbon::getCurrentOpenTimePeriod
no arguments
returns CarbonPeriod|bool
Get current open time range as TimeRange instance or false if closed.
Carbon::getCurrentOpenTimeRangeStart
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
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
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
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
no arguments
Carbon::getSeason
no arguments
returns Season\SeasonEnum
Return the season of the current date.
Carbon::isInSpring
no arguments
returns bool
Return either current date is in spring.
Carbon::isInSummer
no arguments
returns bool
Return either current date is in summer.
Carbon::isInFall
no arguments
returns bool
Return either current date is in fall.
Carbon::isInWinter
no arguments
returns bool
Return either current date is in winter.
Carbon::startOfSeason
no arguments
returns Carbon
Carbon::endOfSeason
no arguments
returns Carbon
CarbonInterval::setTimezone
DateTimeZone|string|int $timezone
returns CarbonInterval
Set the instance's timezone from a string or object.
Prototype changed | 3.0.0 | DateTimeZone|string|int $timezone |
Method added | 2.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 changed | 3.0.0 | DateTimeZone|string|int $timezone |
Method added | 2.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 added | 1.28.0 | no arguments |
CarbonInterval::setCascadeFactors
array $cascadeFactors
Set default cascading factors for ->cascade() method.
Method added | 1.28.0 | array $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 added | 2.70.0 | bool $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 changed | 3.0.0 | $years = null, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null, $microseconds = null |
Prototype changed | 2.0.0 | $years = 1, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null, $microseconds = null |
Method added | 1.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 added | 1.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 added | 2.55.0 | $source, $target |
CarbonInterval::getDaysPerWeek
no arguments
returns int|float
Returns current config for days per week.
Method added | 1.28.0 | no arguments |
CarbonInterval::getHoursPerDay
no arguments
returns int|float
Returns current config for hours per day.
Method added | 1.28.0 | no arguments |
CarbonInterval::getMinutesPerHour
no arguments
returns int|float
Returns current config for minutes per hour.
Method added | 2.0.0 | no arguments |
CarbonInterval::getSecondsPerMinute
no arguments
returns int|float
Returns current config for seconds per minute.
Method added | 2.0.0 | no arguments |
CarbonInterval::getMillisecondsPerSecond
no arguments
returns int|float
Returns current config for microseconds per second.
Method added | 2.0.0 | no arguments |
CarbonInterval::getMicrosecondsPerMillisecond
no arguments
returns int|float
Returns current config for microseconds per second.
Method added | 2.0.0 | no 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 changed | 3.0.0 | $years = null, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null, $microseconds = null |
Prototype changed | 2.5.0 | $years = 1, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null, $microseconds = null |
Method added | 1.18.0 | $years = 1, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null |
CarbonInterval::original
no arguments
returns array|int|string|DateInterval|mixed|null
Return the original source used to create the current interval.
Method added | 3.0.0 | no arguments |
CarbonInterval::start
no arguments
returns CarbonInterface
Return the start date if interval was created from a difference between 2 dates.
Method added | 3.0.0 | no arguments |
CarbonInterval::end
no arguments
returns CarbonInterface
Return the end date if interval was created from a difference between 2 dates.
Method added | 3.0.0 | no 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 added | 3.0.0 | no arguments |
CarbonInterval::copy
no arguments
returns CarbonInterval
Get a copy of the instance.
Method added | 1.28.0 | no arguments |
CarbonInterval::clone
no arguments
returns CarbonInterval
Get a copy of the instance.
Method added | 2.22.0 | no arguments |
CarbonInterval::__set_state
$dump
returns CarbonInterval
Evaluate the PHP generated by var_export() and recreate the exported CarbonInterval instance.
Prototype changed | 2.71.0 | $dump |
Method added | 1.18.0 | array $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 changed | 3.0.0 | string $intervalDefinition |
Method added | 1.25.0 | $intervalDefinition |
CarbonInterval::parseFromLocale
string $interval, ?string $locale = null
returns CarbonInterval
Creates a CarbonInterval from string using a different locale.
Prototype changed | 3.0.0 | string $interval, ?string $locale = null |
Prototype changed | 2.35.0 | $interval, $locale = null |
Method added | 2.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 added | 3.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 added | 3.0.0 | bool $absolute = false |
CarbonInterval::absolute
bool $absolute = true
returns CarbonInterval
@alias abs
Invert the interval if it's inverted.
Method added | 3.0.0 | bool $absolute = true |
CarbonInterval::cast
string $className
returns mixed
Cast the current instance into the given class.
Method added | 2.23.0 | string $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 changed | 2.70.0 | DateInterval $interval, array $skip = [], bool $skipCopy = false |
Prototype changed | 2.64.0 | DateInterval $interval, array $skip = [] |
Prototype changed | 2.21.0 | DateInterval $interval |
Prototype changed | 2.0.0 | DateInterval $di |
Prototype changed | 1.35.0 | DateInterval $di, $trimMicroseconds = true |
Method added | 1.18.0 | DateInterval $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 changed | 2.70.0 | $interval, $unit = null, bool $skipCopy = false |
Prototype changed | 2.34.0 | $interval, $unit = null |
Method added | 1.28.0 | $var |
CarbonInterval::createFromDateString
string $datetime
returns CarbonInterval
Sets up a DateInterval from the relative parts of the string.
Prototype changed | 3.0.0 | string $datetime |
Prototype changed | 2.0.0 | $time |
Prototype changed | 1.21.0 | string $datetime |
Method added | 1.18.0 | $time |
CarbonInterval::get
Carbon\Unit|string $name
returns string|int|float|null
Get a part of the CarbonInterval object.
Prototype changed | 3.1.0 | Carbon\Unit|string $name |
Prototype changed | 3.0.0 | string $name |
Method added | 2.37.0 | $name |
CarbonInterval::__get
string $name
returns string|int|float|null
Get a part of the CarbonInterval object.
Prototype changed | 3.0.0 | string $name |
Method added | 1.18.0 | $name |
CarbonInterval::set
$name, $value = null
returns CarbonInterval
Set a part of the CarbonInterval object.
Method added | 2.37.0 | $name, $value = null |
CarbonInterval::__set
string $name, $value
Set a part of the CarbonInterval object.
Prototype changed | 3.0.0 | string $name, $value |
Prototype changed | 2.0.0 | $name, $value |
Method added | 1.18.0 | $name, $val |
CarbonInterval::weeksAndDays
int $weeks, int $days
returns CarbonInterval
Allow setting of weeks and days to be cumulative.
Prototype changed | 3.0.0 | int $weeks, int $days |
Method added | 1.18.0 | $weeks, $days |
CarbonInterval::isEmpty
no arguments
returns bool
Returns true if the interval is empty for each unit.
Method added | 2.0.0 | no 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 changed | 3.0.1 | string $name, ?callable $macro |
Prototype changed | 3.0.0 | string $name, $macro |
Method added | 1.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";
CarbonInterval::hasMacro
string $name
returns bool
Check if macro is registered.
Prototype changed | 3.0.0 | string $name |
Method added | 1.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 added | 2.27.0 | no 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 added | 2.27.0 | no 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 added | 2.27.0 | no 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 changed | 2.0.0 | $syntax = null, $short = false, $parts = -1, $options = null |
Prototype changed | 1.28.0 | $short = false |
Method added | 1.18.0 | no arguments |
CarbonInterval::__toString
no arguments
returns string
Format the instance as a string using the forHumans() function.
Method added | 1.18.0 | no 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 added | 2.23.0 | no arguments |
CarbonInterval::toPeriod
$params
returns CarbonPeriod
Convert the interval to a CarbonPeriod.
Prototype changed | 2.0.0 | $params |
Method added | 1.29.0 | no arguments |
CarbonInterval::stepBy
$interval, Carbon\Unit|string|null $unit = null
returns CarbonPeriod
Decompose the current interval into
Method added | 3.0.0 | $interval, Carbon\Unit|string|null $unit = null |
CarbonInterval::invert
$inverted = null
returns CarbonInterval
Invert the interval.
Prototype changed | 2.37.0 | $inverted = null |
Method added | 1.28.0 | no arguments |
CarbonInterval::add
$unit, $value = 1
returns CarbonInterval
Add the passed interval to the current instance.
Prototype changed | 2.4.0 | $unit, $value = 1 |
Method added | 1.18.0 | DateInterval $interval |
CarbonInterval::sub
$unit, $value = 1
returns CarbonInterval
Subtract the passed interval to the current instance.
Method added | 2.4.0 | $unit, $value = 1 |
CarbonInterval::subtract
$unit, $value = 1
returns CarbonInterval
Subtract the passed interval to the current instance.
Method added | 2.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 added | 2.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 added | 2.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 added | 1.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 added | 2.20.0 | $divider |
CarbonInterval::multiply
$factor
returns CarbonInterval
Multiply and cascade current instance by a given factor.
Method added | 2.20.0 | $factor |
CarbonInterval::divide
$divider
returns CarbonInterval
Divide and cascade current instance by a given divider.
Method added | 2.20.0 | $divider |
CarbonInterval::getDateIntervalSpec
DateInterval $interval, bool $microseconds = false, array $skip = []
returns string
Get the interval_spec string of a date interval.
Prototype changed | 2.64.0 | DateInterval $interval, bool $microseconds = false, array $skip = [] |
Prototype changed | 2.61.0 | DateInterval $interval, bool $microseconds = false |
Method added | 1.26.0 | DateInterval $interval |
CarbonInterval::spec
bool $microseconds = false
returns string
Get the interval_spec string.
Prototype changed | 2.61.0 | bool $microseconds = false |
Method added | 1.22.0 | no arguments |
CarbonInterval::compareDateIntervals
DateInterval $first, DateInterval $second
returns int
Comparing 2 date intervals.
Prototype changed | 2.21.0 | DateInterval $first, DateInterval $second |
Method added | 1.26.0 | DateInterval $a, DateInterval $b |
CarbonInterval::compare
DateInterval $interval
returns int
Comparing with passed interval.
Method added | 1.24.0 | DateInterval $interval |
CarbonInterval::cascade
no arguments
returns CarbonInterval
Convert overflowed values into bigger units.
Method added | 1.28.0 | no arguments |
CarbonInterval::hasNegativeValues
no arguments
returns bool
Method added | 2.37.0 | no arguments |
CarbonInterval::hasPositiveValues
no arguments
returns bool
Method added | 2.37.0 | no arguments |
CarbonInterval::total
string $unit
returns float
Get amount of given unit equivalent to the interval.
Prototype changed | 3.0.0 | string $unit |
Method added | 1.28.0 | $unit |
CarbonInterval::eq
$interval
returns bool
Determines if the instance is equal to another
Method added | 2.22.0 | $interval |
CarbonInterval::equalTo
$interval
returns bool
Determines if the instance is equal to another
Method added | 2.22.0 | $interval |
CarbonInterval::ne
$interval
returns bool
Determines if the instance is not equal to another
Method added | 2.22.0 | $interval |
CarbonInterval::notEqualTo
$interval
returns bool
Determines if the instance is not equal to another
Method added | 2.22.0 | $interval |
CarbonInterval::gt
$interval
returns bool
Determines if the instance is greater (longer) than another
Method added | 2.22.0 | $interval |
CarbonInterval::greaterThan
$interval
returns bool
Determines if the instance is greater (longer) than another
Method added | 2.22.0 | $interval |
CarbonInterval::gte
$interval
returns bool
Determines if the instance is greater (longer) than or equal to another
Method added | 2.22.0 | $interval |
CarbonInterval::greaterThanOrEqualTo
$interval
returns bool
Determines if the instance is greater (longer) than or equal to another
Method added | 2.22.0 | $interval |
CarbonInterval::lt
$interval
returns bool
Determines if the instance is less (shorter) than another
Method added | 2.22.0 | $interval |
CarbonInterval::lessThan
$interval
returns bool
Determines if the instance is less (shorter) than another
Method added | 2.22.0 | $interval |
CarbonInterval::lte
$interval
returns bool
Determines if the instance is less (shorter) than or equal to another
Method added | 2.22.0 | $interval |
CarbonInterval::lessThanOrEqualTo
$interval
returns bool
Determines if the instance is less (shorter) than or equal to another
Method added | 2.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));
CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::hours(36));
CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::days(2));
CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::days(2), false);
Prototype changed | 3.0.0 | $interval1, $interval2, bool $equal = true |
Method added | 2.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));
CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::hours(36));
CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::days(2));
Method added | 2.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));
CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::hours(36));
CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::days(2));
Method added | 2.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));
CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::hours(36));
CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::days(2));
CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::days(2), false);
Prototype changed | 3.0.0 | $interval1, $interval2, bool $equal = true |
Method added | 2.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 changed | 3.0.0 | string $unit, DateInterval|string|int|float $precision = 1, string $function = 'round' |
Method added | 2.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 changed | 3.0.0 | string $unit, $precision = 1 |
Method added | 2.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 changed | 3.0.0 | string $unit, $precision = 1 |
Method added | 2.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 changed | 3.0.0 | $precision = 1, string $function = 'round' |
Method added | 2.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 changed | 3.0.0 | DateInterval|string|int|float $precision = 1 |
Method added | 2.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 changed | 3.0.0 | DateInterval|string|int|float $precision = 1 |
Method added | 2.23.0 | $precision = 1 |
CarbonInterval::__unserialize
array $data
Set locale if specified on unserialize() called.
Only used by PHP >= 7.4.
Method added | 1.21.0 | array $data |
CarbonInterval::getClock
no arguments
returns WrapperClock
Method added | 3.0.0 | no arguments |
CarbonInterval::getStep
no arguments
returns Closure
Get the dynamic step in use.
Method added | 2.36.0 | no 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 added | 2.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 added | 2.36.0 | DateTimeInterface $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 changed | 3.0.0 | object|string $mixin |
Method added | 2.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 added | 2.0.0 | array $settings |
CarbonInterval::getSettings
no arguments
returns array
Returns current local settings.
Method added | 2.3.0 | no arguments |
CarbonInterval::__debugInfo
no arguments
returns array
Show truthy properties on \Carbon\Doc\Generate\var_dump().
Method added | 2.17.0 | no 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 changed | 3.0.0 | bool $strictModeEnabled = true |
Method added | 2.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 added | 2.0.0 | no 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 changed | 3.0.0 | bool $monthsOverflow = true |
Method added | 2.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 added | 2.0.0 | no arguments |
CarbonInterval::shouldOverflowMonths
no arguments
returns bool
Get the month overflow global behavior (can be overridden in specific instances).
Method added | 2.0.0 | no 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 changed | 3.0.0 | bool $yearsOverflow = true |
Method added | 2.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 added | 2.0.0 | no arguments |
CarbonInterval::shouldOverflowYears
no arguments
returns bool
Get the month overflow global behavior (can be overridden in specific instances).
Method added | 2.0.0 | no arguments |
CarbonInterval::hasLocalTranslator
no arguments
returns bool
Return true if the current instance has its own translator.
Method added | 2.29.0 | no arguments |
CarbonInterval::getLocalTranslator
no arguments
returns Symfony\Contracts\Translation\TranslatorInterface
Get the translator of the current instance or the default if none set.
Method added | 2.0.0 | no arguments |
CarbonInterval::setLocalTranslator
Symfony\Contracts\Translation\TranslatorInterface $translator
returns CarbonInterval
Set the translator for the current instance.
Prototype changed | 3.0.0 | Symfony\Contracts\Translation\TranslatorInterface $translator |
Method added | 2.0.0 | Symfony\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 added | 2.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 added | 2.8.0 | string $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 changed | 3.0.0 | Symfony\Contracts\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null |
Method added | 2.8.0 | Symfony\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 changed | 3.0.0 | string $key, array $parameters = [], string|int|float|null $number = null, ?Symfony\Contracts\Translation\TranslatorInterface $translator = null, bool $altNumbers = false |
Prototype changed | 2.23.0 | string $key, array $parameters = [], $number = null, ?Symfony\Component\Translation\TranslatorInterface $translator = null, bool $altNumbers = false |
Method added | 2.8.0 | string $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 added | 2.23.0 | int $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 changed | 3.0.0 | string $timeString, ?string $from = null, ?string $to = null, int $mode = 31 |
Prototype changed | 2.35.0 | $timeString, $from = null, $to = null, $mode = 31 |
Method added | 2.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 changed | 3.0.0 | string $timeString, ?string $to = null |
Method added | 2.16.0 | $timeString, $to = null |
CarbonInterval::locale
?string $locale = null, string $fallbackLocales
returns CarbonInterval|string
Get/set the locale for the current instance.
Prototype changed | 3.0.0 | ?string $locale = null, string $fallbackLocales |
Prototype changed | 2.16.0 | ?string $locale = null, $fallbackLocales |
Method added | 2.0.0 | ?string $locale = null |
CarbonInterval::getLocale
no arguments
returns string
Get the current translator locale.
Method added | 1.18.0 | no 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 changed | 3.0.0 | string $locale |
Method added | 1.18.0 | $locale |
CarbonInterval::setFallbackLocale
string $locale
Set the fallback locale.
Prototype changed | 3.0.0 | string $locale |
Method added | 2.16.0 | $locale |
CarbonInterval::getFallbackLocale
no arguments
returns string
Get the fallback locale.
Method added | 2.16.0 | no 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 changed | 3.0.0 | string $locale, callable $func |
Method added | 2.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 changed | 3.0.0 | string $locale |
Method added | 2.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 changed | 3.0.0 | string $locale |
Method added | 2.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 changed | 3.0.0 | string $locale |
Method added | 2.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 changed | 3.0.0 | string $locale |
Method added | 2.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.
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 added | 2.0.0 | no 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 added | 2.10.1 | no 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 changed | 3.0.0 | int $humanDiffOptions |
Method added | 2.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 changed | 3.0.0 | int $humanDiffOption |
Method added | 2.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 changed | 3.0.0 | int $humanDiffOption |
Method added | 2.0.0 | $humanDiffOption |
CarbonInterval::getHumanDiffOptions
no arguments
returns int
Return default humanDiff() options (merged flags as integer).
Method added | 2.0.0 | no arguments |
CarbonInterval::setTranslator
Symfony\Contracts\Translation\TranslatorInterface $translator
Set the default translator instance to use.
Prototype changed | 3.0.0 | Symfony\Contracts\Translation\TranslatorInterface $translator |
Method added | 1.18.0 | Symfony\Component\Translation\TranslatorInterface $translator |
CarbonInterval::getTranslator
no arguments
returns Symfony\Contracts\Translation\TranslatorInterface
Initialize the default translator instance if necessary.
Method added | 1.18.0 | no arguments |
CarbonPeriod::getIterator
no arguments
returns Generator
Method added | 3.0.0 | no arguments |
CarbonPeriod::make
mixed $var
returns CarbonPeriod
Make a CarbonPeriod instance from given variable if possible.
Prototype changed | 3.0.0 | mixed $var |
Method added | 2.22.0 | $var |
CarbonPeriod::instance
mixed $period
returns CarbonPeriod
Create a new instance from a DatePeriod or CarbonPeriod object.
Prototype changed | 3.0.0 | mixed $period |
Method added | 2.22.0 | $period |
CarbonPeriod::create
$params
returns CarbonPeriod
Create a new instance.
Prototype changed | 2.0.0 | $params |
Method added | 1.29.0 | no arguments |
CarbonPeriod::createFromArray
array $params
returns CarbonPeriod
Create a new instance from an array of parameters.
Method added | 1.29.0 | array $params |
CarbonPeriod::createFromIso
string $iso, ?int $options = null
returns CarbonPeriod
Create CarbonPeriod from ISO 8601 string.
Prototype changed | 3.0.0 | string $iso, ?int $options = null |
Method added | 1.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 changed | 3.0.1 | string $name, ?callable $macro |
Prototype changed | 3.0.0 | string $name, $macro |
Method added | 1.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 changed | 3.0.0 | object|string $mixin |
Method added | 1.29.0 | $mixin |
CarbonPeriod::hasMacro
string $name
returns bool
Check if macro is registered.
Prototype changed | 3.0.0 | string $name |
Method added | 1.29.0 | $name |
CarbonPeriod::__construct
$arguments
CarbonPeriod constructor.
Prototype changed | 2.0.0 | $arguments |
Method added | 1.29.0 | no arguments |
CarbonPeriod::copy
no arguments
returns CarbonPeriod
Get a copy of the instance.
Method added | 2.22.0 | no arguments |
CarbonPeriod::get
string $name
returns bool|CarbonInterface|CarbonInterval|int|null
Get a property allowing both `DatePeriod` snakeCase and camelCase names.
Method added | 2.45.0 | string $name |
CarbonPeriod::__get
string $name
returns bool|CarbonInterface|CarbonInterval|int|null
Get a property allowing both `DatePeriod` snakeCase and camelCase names.
Method added | 2.41.0 | string $name |
CarbonPeriod::__isset
string $name
returns bool
Check if an attribute exists on the object
Method added | 2.41.0 | string $name |
CarbonPeriod::clone
no arguments
returns CarbonPeriod
@alias copy
Get a copy of the instance.
Method added | 2.22.0 | no arguments |
CarbonPeriod::setDateClass
string $dateClass
returns CarbonPeriod
Set the iteration item class.
Method added | 2.0.0 | string $dateClass |
CarbonPeriod::getDateClass
no arguments
returns string
Returns iteration item date class.
Method added | 2.0.0 | no arguments |
CarbonPeriod::setDateInterval
mixed $interval, Carbon\Unit|string|null $unit = null
returns CarbonPeriod
Change the period date interval.
Prototype changed | 3.0.0 | mixed $interval, Carbon\Unit|string|null $unit = null |
Method added | 1.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 added | 3.0.0 | no arguments |
CarbonPeriod::invertDateInterval
no arguments
returns CarbonPeriod
Invert the period date interval.
Method added | 1.29.0 | no arguments |
CarbonPeriod::setDates
mixed $start, mixed $end
returns CarbonPeriod
Set start and end date.
Prototype changed | 3.0.0 | mixed $start, mixed $end |
Method added | 1.29.0 | $start, $end |
CarbonPeriod::setOptions
?int $options
returns CarbonPeriod
Change the period options.
Prototype changed | 3.0.0 | ?int $options |
Method added | 1.29.0 | $options |
CarbonPeriod::getOptions
no arguments
returns int
Get the period options.
Method added | 1.29.0 | no arguments |
CarbonPeriod::toggleOptions
int $options, ?bool $state = null
returns CarbonPeriod
Toggle given options on or off.
Prototype changed | 3.0.0 | int $options, ?bool $state = null |
Method added | 1.29.0 | $options, $state = null |
CarbonPeriod::excludeStartDate
bool $state = true
returns CarbonPeriod
Toggle EXCLUDE_START_DATE option.
Prototype changed | 3.0.0 | bool $state = true |
Method added | 1.29.0 | $state = true |
CarbonPeriod::excludeEndDate
bool $state = true
returns CarbonPeriod
Toggle EXCLUDE_END_DATE option.
Prototype changed | 3.0.0 | bool $state = true |
Method added | 1.29.0 | $state = true |
CarbonPeriod::getDateInterval
no arguments
returns CarbonInterval
Get the underlying date interval.
Method added | 1.29.0 | no arguments |
CarbonPeriod::getStartDate
?string $rounding = null
returns CarbonInterface
Get start date of the period.
Prototype changed | 2.23.0 | ?string $rounding = null |
Method added | 1.29.0 | no arguments |
CarbonPeriod::getEndDate
?string $rounding = null
returns CarbonInterface
Get end date of the period.
Prototype changed | 2.23.0 | ?string $rounding = null |
Method added | 1.29.0 | no arguments |
CarbonPeriod::getRecurrences
no arguments
returns int|float|null
Get number of recurrences.
Method added | 1.29.0 | no arguments |
CarbonPeriod::isStartExcluded
no arguments
returns bool
Returns true if the start date should be excluded.
Method added | 1.29.0 | no arguments |
CarbonPeriod::isEndExcluded
no arguments
returns bool
Returns true if the end date should be excluded.
Method added | 1.29.0 | no arguments |
CarbonPeriod::isStartIncluded
no arguments
returns bool
Returns true if the start date should be included.
Method added | 2.23.0 | no arguments |
CarbonPeriod::isEndIncluded
no arguments
returns bool
Returns true if the end date should be included.
Method added | 2.23.0 | no arguments |
CarbonPeriod::getIncludedStartDate
no arguments
returns CarbonInterface
Return the start if it's included by option, else return the start + 1 period interval.
Method added | 2.23.0 | no 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 added | 2.23.0 | no arguments |
CarbonPeriod::addFilter
callable|string $callback, ?string $name = null
returns CarbonPeriod
Add a filter to the stack.
Prototype changed | 3.0.0 | callable|string $callback, ?string $name = null |
Method added | 1.29.0 | $callback, $name = null |
CarbonPeriod::prependFilter
callable|string $callback, ?string $name = null
returns CarbonPeriod
Prepend a filter to the stack.
Prototype changed | 3.0.0 | callable|string $callback, ?string $name = null |
Method added | 1.29.0 | $callback, $name = null |
CarbonPeriod::removeFilter
callable|string $filter
returns CarbonPeriod
Remove a filter by instance or name.
Prototype changed | 3.0.0 | callable|string $filter |
Method added | 1.29.0 | $filter |
CarbonPeriod::hasFilter
callable|string $filter
returns bool
Return whether given instance or name is in the filter stack.
Prototype changed | 3.0.0 | callable|string $filter |
Method added | 1.29.0 | $filter |
CarbonPeriod::getFilters
no arguments
returns array
Get filters stack.
Method added | 1.29.0 | no arguments |
CarbonPeriod::setFilters
array $filters
returns CarbonPeriod
Set filters stack.
Method added | 1.29.0 | array $filters |
CarbonPeriod::resetFilters
no arguments
returns CarbonPeriod
Reset filters stack.
Method added | 1.29.0 | no arguments |
CarbonPeriod::setRecurrences
int|float|null $recurrences
returns CarbonPeriod
Add a recurrences filter (set maximum number of recurrences).
Prototype changed | 3.0.0 | int|float|null $recurrences |
Method added | 1.29.0 | $recurrences |
CarbonPeriod::setStartDate
mixed $date, ?bool $inclusive = null
returns CarbonPeriod
Change the period start date.
Prototype changed | 3.0.0 | mixed $date, ?bool $inclusive = null |
Method added | 1.29.0 | $date, $inclusive = null |
CarbonPeriod::setEndDate
mixed $date, ?bool $inclusive = null
returns CarbonPeriod
Change the period end date.
Prototype changed | 3.0.0 | mixed $date, ?bool $inclusive = null |
Method added | 1.29.0 | $date, $inclusive = null |
CarbonPeriod::valid
no arguments
returns bool
Check if the current position is valid.
Method added | 1.29.0 | no arguments |
CarbonPeriod::key
no arguments
returns int
Return the current key.
Method added | 1.29.0 | no arguments |
CarbonPeriod::current
no arguments
returns CarbonInterface
Return the current date.
Method added | 1.29.0 | no arguments |
CarbonPeriod::next
no arguments
Move forward to the next date.
Method added | 1.29.0 | no 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 added | 1.29.0 | no arguments |
CarbonPeriod::skip
int $count = 1
returns bool
Skip iterations and returns iteration state (false if ended, true if still valid).
Prototype changed | 3.0.0 | int $count = 1 |
Method added | 1.30.0 | $count = 1 |
CarbonPeriod::toIso8601String
no arguments
returns string
Format the date period as ISO 8601.
Method added | 1.29.0 | no arguments |
CarbonPeriod::toString
no arguments
returns string
Convert the date period into a string.
Method added | 1.29.0 | no arguments |
CarbonPeriod::spec
no arguments
returns string
Format the date period as ISO 8601.
Method added | 1.29.0 | no arguments |
CarbonPeriod::cast
string $className
returns object
Cast the current instance into the given class.
Method added | 2.23.0 | string $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 added | 2.23.0 | no 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 added | 2.59.0 | no arguments |
CarbonPeriod::toArray
no arguments
returns array
Convert the date period into an array without changing current iteration state.
Method added | 1.29.0 | no arguments |
CarbonPeriod::count
no arguments
returns int
Count dates in the date period.
Method added | 1.29.0 | no arguments |
CarbonPeriod::first
no arguments
returns CarbonInterface
Return the first date in the date period.
Method added | 1.29.0 | no arguments |
CarbonPeriod::last
no arguments
returns CarbonInterface
Return the last date in the date period.
Method added | 1.29.0 | no arguments |
CarbonPeriod::__toString
no arguments
returns string
Convert the date period into a string.
Method added | 1.29.0 | no 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 changed | 3.0.0 | DateTimeZone|string|int $timezone |
Method added | 2.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 changed | 3.0.0 | DateTimeZone|string|int $timezone |
Method added | 2.3.0 | $timezone |
CarbonPeriod::calculateEnd
?string $rounding = null
returns CarbonInterface
Returns the end is set, else calculated from start and recurrences.
Prototype changed | 2.23.0 | ?string $rounding = null |
Method added | 2.20.0 | no 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 changed | 3.0.0 | mixed $rangeOrRangeStart, mixed $rangeEnd = null |
Method added | 2.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 added | 2.22.0 | callable $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 added | 2.22.0 | callable $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 changed | 3.0.0 | mixed $period |
Method added | 2.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 changed | 3.0.0 | mixed $period |
Method added | 2.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 changed | 3.0.0 | mixed $period |
Method added | 2.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 changed | 3.0.0 | mixed $period |
Method added | 2.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 changed | 3.0.0 | mixed $date = null |
Method added | 2.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 changed | 3.0.0 | mixed $date = null |
Method added | 2.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 changed | 3.0.0 | mixed $date = null |
Method added | 2.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 changed | 3.0.0 | mixed $date = null |
Method added | 2.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 changed | 3.0.0 | mixed $date = null |
Method added | 2.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 changed | 3.0.0 | mixed $date = null |
Method added | 2.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 changed | 3.0.0 | mixed $date = null |
Method added | 2.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 changed | 3.0.0 | mixed $date = null |
Method added | 2.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 changed | 3.0.0 | mixed $date = null |
Method added | 2.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 changed | 3.0.0 | mixed $date = null |
Method added | 2.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 added | 2.23.0 | no 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 added | 2.23.0 | no 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 added | 2.23.0 | no 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 changed | 3.0.0 | string $unit, DateInterval|string|int|float|null $precision = 1, callable|string $function = 'round' |
Method added | 2.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 changed | 3.0.0 | string $unit, DateInterval|string|int|float|null $precision = 1 |
Method added | 2.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 changed | 3.0.0 | string $unit, DateInterval|string|int|float|null $precision = 1 |
Method added | 2.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 changed | 3.0.0 | DateInterval|string|int|float|null $precision = null, callable|string $function = 'round' |
Method added | 2.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 changed | 3.0.0 | DateInterval|string|int|float|null $precision = null |
Method added | 2.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 changed | 3.0.0 | DateInterval|string|int|float|null $precision = null |
Method added | 2.23.0 | $precision = null |
CarbonPeriod::jsonSerialize
no arguments
returns array
Specify data which should be serialized to JSON.
Method added | 2.23.0 | no arguments |
CarbonPeriod::contains
mixed $date = null
returns bool
Return true if the given date is between start and end.
Prototype changed | 3.0.0 | mixed $date = null |
Method added | 2.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 changed | 3.0.0 | mixed $period, mixed $arguments |
Method added | 2.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 changed | 3.0.0 | mixed $period, mixed $arguments |
Method added | 2.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 changed | 3.0.0 | mixed $period, mixed $arguments |
Method added | 2.23.0 | $period, $arguments |
CarbonPeriod::__debugInfo
no arguments
returns array
Show truthy properties on \Carbon\Doc\Generate\var_dump().
Method added | 2.17.0 | no arguments |
CarbonPeriod::createFromISO8601String
string $specification, int $options = 0
returns CarbonPeriod
Method added | 3.0.0 | string $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 added | 3.0.0 | no arguments |
CarbonPeriod::__unserialize
array $data
Set locale if specified on unserialize() called.
Only used by PHP >= 7.4.
Method added | 3.0.0 | array $data |
CarbonPeriod::__wakeup
no arguments
Set locale if specified on unserialize() called.
Only used by PHP < 7.4.
Method added | 3.0.0 | no arguments |
CarbonPeriod::__set_state
array $array
returns CarbonPeriod
The __set_state handler.
Method added | 3.0.0 | array $array |
CarbonPeriod::getClock
no arguments
returns WrapperClock
Method added | 3.0.0 | no 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 changed | 3.0.0 | object|string $mixin |
Method added | 2.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 added | 2.0.0 | array $settings |
CarbonPeriod::getSettings
no arguments
returns array
Returns current local settings.
Method added | 2.3.0 | no arguments |
CarbonPeriod::baseDebugInfo
no arguments
returns array
Show truthy properties on \Carbon\Doc\Generate\var_dump().
Method added | 3.0.0 | no 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 changed | 3.0.0 | bool $strictModeEnabled = true |
Method added | 2.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 added | 2.0.0 | no 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 changed | 3.0.0 | bool $monthsOverflow = true |
Method added | 2.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 added | 2.0.0 | no arguments |
CarbonPeriod::shouldOverflowMonths
no arguments
returns bool
Get the month overflow global behavior (can be overridden in specific instances).
Method added | 2.0.0 | no 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 changed | 3.0.0 | bool $yearsOverflow = true |
Method added | 2.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 added | 2.0.0 | no arguments |
CarbonPeriod::shouldOverflowYears
no arguments
returns bool
Get the month overflow global behavior (can be overridden in specific instances).
Method added | 2.0.0 | no arguments |
CarbonPeriod::hasLocalTranslator
no arguments
returns bool
Return true if the current instance has its own translator.
Method added | 2.29.0 | no arguments |
CarbonPeriod::getLocalTranslator
no arguments
returns Symfony\Contracts\Translation\TranslatorInterface
Get the translator of the current instance or the default if none set.
Method added | 2.0.0 | no arguments |
CarbonPeriod::setLocalTranslator
Symfony\Contracts\Translation\TranslatorInterface $translator
returns CarbonPeriod
Set the translator for the current instance.
Prototype changed | 3.0.0 | Symfony\Contracts\Translation\TranslatorInterface $translator |
Method added | 2.0.0 | Symfony\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 added | 2.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 added | 2.8.0 | string $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 changed | 3.0.0 | Symfony\Contracts\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null |
Method added | 2.8.0 | Symfony\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 changed | 3.0.0 | string $key, array $parameters = [], string|int|float|null $number = null, ?Symfony\Contracts\Translation\TranslatorInterface $translator = null, bool $altNumbers = false |
Prototype changed | 2.23.0 | string $key, array $parameters = [], $number = null, ?Symfony\Component\Translation\TranslatorInterface $translator = null, bool $altNumbers = false |
Method added | 2.8.0 | string $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 added | 2.23.0 | int $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 changed | 3.0.0 | string $timeString, ?string $from = null, ?string $to = null, int $mode = 31 |
Prototype changed | 2.35.0 | $timeString, $from = null, $to = null, $mode = 31 |
Method added | 2.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 changed | 3.0.0 | string $timeString, ?string $to = null |
Method added | 2.16.0 | $timeString, $to = null |
CarbonPeriod::locale
?string $locale = null, string $fallbackLocales
returns CarbonPeriod|string
Get/set the locale for the current instance.
Prototype changed | 3.0.0 | ?string $locale = null, string $fallbackLocales |
Prototype changed | 2.16.0 | ?string $locale = null, $fallbackLocales |
Method added | 2.0.0 | ?string $locale = null |
CarbonPeriod::getLocale
no arguments
returns string
Get the current translator locale.
Method added | 2.0.0 | no 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 changed | 3.0.0 | string $locale |
Method added | 2.0.0 | $locale |
CarbonPeriod::setFallbackLocale
string $locale
Set the fallback locale.
Prototype changed | 3.0.0 | string $locale |
Method added | 2.16.0 | $locale |
CarbonPeriod::getFallbackLocale
no arguments
returns string
Get the fallback locale.
Method added | 2.16.0 | no 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 changed | 3.0.0 | string $locale, callable $func |
Method added | 2.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 changed | 3.0.0 | string $locale |
Method added | 2.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 changed | 3.0.0 | string $locale |
Method added | 2.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 changed | 3.0.0 | string $locale |
Method added | 2.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 changed | 3.0.0 | string $locale |
Method added | 2.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.
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 added | 2.0.0 | no 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 added | 2.10.1 | no 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 changed | 3.0.0 | int $humanDiffOptions |
Method added | 2.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 changed | 3.0.0 | int $humanDiffOption |
Method added | 2.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 changed | 3.0.0 | int $humanDiffOption |
Method added | 2.0.0 | $humanDiffOption |
CarbonPeriod::getHumanDiffOptions
no arguments
returns int
Return default humanDiff() options (merged flags as integer).
Method added | 2.0.0 | no arguments |
CarbonPeriod::setTranslator
Symfony\Contracts\Translation\TranslatorInterface $translator
Set the default translator instance to use.
Prototype changed | 3.0.0 | Symfony\Contracts\Translation\TranslatorInterface $translator |
Method added | 2.0.0 | Symfony\Component\Translation\TranslatorInterface $translator |
CarbonPeriod::getTranslator
no arguments
returns Symfony\Contracts\Translation\TranslatorInterface
Initialize the default translator instance if necessary.
Method added | 2.0.0 | no arguments |
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 changed | 3.0.0 | string|int|float $timezone |
Method added | 2.0.0 | $timezone = null |
CarbonTimeZone::cast
string $className
returns mixed
Cast the current instance into the given class.
Method added | 2.23.0 | string $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 changed | 3.0.0 | DateTimeZone|string|int|false|null $object, DateTimeZone|string|int|false|null $objectDump = null |
Prototype changed | 2.10.0 | $object = null, $objectDump = null |
Method added | 2.0.0 | $object = null |
CarbonTimeZone::getAbbreviatedName
bool $dst = false
returns string
Returns abbreviated name of the current timezone according to DST setting.
Prototype changed | 3.0.0 | bool $dst = false |
Method added | 2.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 changed | 3.0.0 | bool $dst = false |
Method added | 2.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 added | 2.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 added | 2.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 changed | 3.0.0 | ?DateTimeInterface $date = null, int $isDST = 1 |
Method added | 2.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 added | 2.10.0 | ?DateTimeInterface $date = null |
CarbonTimeZone::__toString
no arguments
returns string
Cast to string (get timezone name).
Method added | 2.10.0 | no 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 added | 2.61.0 | no arguments |
CarbonTimeZone::create
$object = null
returns false|CarbonTimeZone
Create a CarbonTimeZone from mixed input.
Method added | 2.0.0 | $object = null |
CarbonTimeZone::createFromHourOffset
float $hourOffset
returns false|CarbonTimeZone
Create a CarbonTimeZone from int/float hour offset.
Method added | 2.33.0 | float $hourOffset |
CarbonTimeZone::createFromMinuteOffset
float $minuteOffset
returns false|CarbonTimeZone
Create a CarbonTimeZone from int/float minute offset.
Method added | 2.33.0 | float $minuteOffset |
CarbonTimeZone::getOffsetNameFromMinuteOffset
float $minutes
returns string
Convert a total minutes offset into a standardized timezone offset string.
Method added | 2.33.0 | float $minutes |
CarbonTimeZone::getClock
no arguments
returns WrapperClock
Method added | 3.0.0 | no arguments |
Translator::trans
?string $id, array $parameters = [], ?string $domain = null, ?string $locale = null
returns string
Prototype changed | 2.55.0 | ?string $id, array $parameters = [], ?string $domain = null, ?string $locale = null |
Method added | 1.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 added | 2.55.0 | Symfony\Component\Translation\MessageCatalogueInterface $catalogue, string $id, string $domain = 'messages' |
Translator::get
?string $locale = null
returns Translator
Return a singleton instance of Translator.
Prototype changed | 3.0.0 | ?string $locale = null |
Method added | 1.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.
Method added | 1.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 added | 2.0.0 | no arguments |
Translator::setDirectories
array $directories
returns Translator
Set list of directories translation files are searched in.
Method added | 2.0.0 | array $directories |
Translator::addDirectory
string $directory
returns Translator
Add a directory to the list translation files are searched in.
Method added | 2.0.0 | string $directory |
Translator::removeDirectory
string $directory
returns Translator
Remove a directory from the list translation files are searched in.
Method added | 2.0.0 | string $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 changed | 3.0.0 | ?string $locale = null |
Method added | 1.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 changed | 3.0.0 | string $prefix = '' |
Method added | 2.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 changed | 3.0.0 | string $prefix = '' |
Method added | 2.0.0 | $prefix = '' |
Translator::setMessages
string $locale, array $messages
returns Translator
Set messages of a locale and take file first if present.
Prototype changed | 3.0.0 | string $locale, array $messages |
Method added | 1.25.0 | $locale, $messages |
Translator::setTranslations
array $messages
returns Translator
Set messages of the current locale and take file first if present.
Prototype changed | 3.0.0 | array $messages |
Method added | 2.9.0 | $messages |
Translator::getMessages
?string $locale = null
returns array
Get messages of a locale, if none given, return all the
languages.
Prototype changed | 3.0.0 | ?string $locale = null |
Method added | 1.25.0 | $locale = null |
Translator::setLocale
$locale
Set the current translator locale and indicate if the source locale file exists
Method added | 1.25.0 | $locale |
Translator::__debugInfo
no arguments
returns array
Show locale on \Carbon\Doc\Generate\var_dump().
Method added | 2.17.0 | no arguments |
Translator::__serialize
no arguments
returns array
Returns the values to dump on serialize() called on.
Only used by PHP >= 7.4.
Method added | 3.3.1 | no arguments |
Translator::__unserialize
array $data
Set locale if specified on unserialize() called.
Only used by PHP >= 7.4.
Method added | 3.3.1 | array $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 added | 2.10.1 | string $id |
Language::all
no arguments
returns array
Get the list of the known languages.
Method added | 2.10.1 | no 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 added | 2.10.1 | no arguments |
Language::getNames
no arguments
returns array
Get both isoName and nativeName as an array.
Method added | 2.10.1 | no arguments |
Language::getId
no arguments
returns string
Returns the original locale ID.
Method added | 2.10.1 | no arguments |
Language::getCode
no arguments
returns string
Returns the code of the locale "en"/"fr".
Method added | 2.10.1 | no arguments |
Language::getVariant
no arguments
returns string
Returns the variant code such as cyrl/latn.
Method added | 2.10.1 | no arguments |
Language::getVariantName
no arguments
returns string
Returns the variant such as Cyrillic/Latin.
Method added | 2.10.1 | no arguments |
Language::getRegion
no arguments
returns string
Returns the region part of the locale.
Method added | 2.10.1 | no 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 added | 2.10.1 | no arguments |
Language::getFullIsoName
no arguments
returns string
Returns the long ISO language name.
Method added | 2.10.1 | no arguments |
Language::setIsoName
string $isoName
returns Language
Set the ISO language name.
Method added | 2.10.1 | string $isoName |
Language::getFullNativeName
no arguments
returns string
Return the full name of the language in this language.
Method added | 2.10.1 | no arguments |
Language::setNativeName
string $nativeName
returns Language
Set the name of the language in this language.
Method added | 2.10.1 | string $nativeName |
Language::getIsoName
no arguments
returns string
Returns the short ISO language name.
Method added | 2.10.1 | no arguments |
Language::getNativeName
no arguments
returns string
Get the short name of the language in this language.
Method added | 2.10.1 | no 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 added | 2.10.1 | no 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 added | 2.10.1 | no 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 added | 2.10.1 | no 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 added | 2.10.1 | no arguments |
Language::__toString
no arguments
returns string
Returns the original locale ID.
Method added | 2.10.1 | no 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 added | 2.10.1 | no arguments |
Carbon::isUtc
no arguments
returns bool
Check if the current instance has UTC timezone. (Both isUtc and isUTC cases are valid.)
Method added | 2.0.0 | no arguments |
Carbon::isLocal
no arguments
returns bool
Check if the current instance has non-UTC timezone.
Method added | 2.0.0 | no arguments |
Carbon::isValid
no arguments
returns bool
Check if the current instance is a valid date.
Method added | 2.0.0 | no arguments |
Carbon::isDST
no arguments
returns bool
Check if the current instance is in a daylight saving time.
Method added | 2.0.0 | no arguments |
Carbon::isSunday
no arguments
returns bool
Checks if the instance day is sunday.
Method added | 1.20.0 | no arguments |
Carbon::isMonday
no arguments
returns bool
Checks if the instance day is monday.
Method added | 1.20.0 | no arguments |
Carbon::isTuesday
no arguments
returns bool
Checks if the instance day is tuesday.
Method added | 1.20.0 | no arguments |
Carbon::isWednesday
no arguments
returns bool
Checks if the instance day is wednesday.
Method added | 1.20.0 | no arguments |
Carbon::isThursday
no arguments
returns bool
Checks if the instance day is thursday.
Method added | 1.20.0 | no arguments |
Carbon::isFriday
no arguments
returns bool
Checks if the instance day is friday.
Method added | 1.20.0 | no arguments |
Carbon::isSaturday
no arguments
returns bool
Checks if the instance day is saturday.
Method added | 1.20.0 | no 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 changed | 3.2.0 | DateTimeInterface|string $date |
Prototype changed | 2.34.2 | Carbon|DateTimeInterface|string|null $date = null |
Prototype changed | 2.24.0 | \Carbon\Carbon|\DateTimeInterface|string|null $date = null |
Prototype changed | 2.0.0 | \DateTimeInterface $date = null |
Prototype changed | 1.23.0 | $date = null |
Method added | 1.22.0 | ?Carbon\Carbon $date = null |
Carbon::isCurrentYear
no arguments
returns bool
Checks if the instance is in the same year as the current moment.
Method added | 1.22.0 | no arguments |
Carbon::isNextYear
no arguments
returns bool
Checks if the instance is in the same year as the current moment next year.
Method added | 1.22.0 | no arguments |
Carbon::isLastYear
no arguments
returns bool
Checks if the instance is in the same year as the current moment last year.
Method added | 1.22.0 | no arguments |
Carbon::isCurrentMonth
no arguments
returns bool
Checks if the instance is in the same month as the current moment.
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.29.2 | $ofSameYear = null |
Method added | 1.22.0 | no arguments |
Carbon::isNextMonth
no arguments
returns bool
Checks if the instance is in the same month as the current moment next month.
Method added | 1.22.0 | no arguments |
Carbon::isLastMonth
no arguments
returns bool
Checks if the instance is in the same month as the current moment last month.
Method added | 1.22.0 | no 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 changed | 3.2.0 | DateTimeInterface|string $date |
Prototype changed | 2.34.2 | Carbon|DateTimeInterface|string|null $date = null |
Prototype changed | 2.24.0 | \Carbon\Carbon|\DateTimeInterface|string|null $date = null |
Method added | 2.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 added | 2.0.0 | no arguments |
Carbon::isNextWeek
no arguments
returns bool
Checks if the instance is in the same week as the current moment next week.
Method added | 1.22.0 | no arguments |
Carbon::isLastWeek
no arguments
returns bool
Checks if the instance is in the same week as the current moment last week.
Method added | 1.22.0 | no 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 changed | 3.2.0 | DateTimeInterface|string $date |
Prototype changed | 2.34.2 | Carbon|DateTimeInterface|string|null $date = null |
Prototype changed | 2.24.0 | \Carbon\Carbon|\DateTimeInterface|string|null $date = null |
Prototype changed | 2.0.0 | \DateTimeInterface $date = null |
Prototype changed | 1.27.0 | $date = null |
Prototype changed | 1.23.0 | $date |
Method added | 1.11.0 | Carbon\Carbon $date |
Carbon::isCurrentDay
no arguments
returns bool
Checks if the instance is in the same day as the current moment.
Method added | 1.27.0 | no arguments |
Carbon::isNextDay
no arguments
returns bool
Checks if the instance is in the same day as the current moment next day.
Method added | 2.0.0 | no arguments |
Carbon::isLastDay
no arguments
returns bool
Checks if the instance is in the same day as the current moment last day.
Method added | 2.0.0 | no 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 changed | 3.2.0 | DateTimeInterface|string $date |
Prototype changed | 2.34.2 | Carbon|DateTimeInterface|string|null $date = null |
Prototype changed | 2.24.0 | \Carbon\Carbon|\DateTimeInterface|string|null $date = null |
Prototype changed | 2.0.0 | \DateTimeInterface $date = null |
Method added | 1.27.0 | $date = null |
Carbon::isCurrentHour
no arguments
returns bool
Checks if the instance is in the same hour as the current moment.
Method added | 1.27.0 | no arguments |
Carbon::isNextHour
no arguments
returns bool
Checks if the instance is in the same hour as the current moment next hour.
Method added | 2.0.0 | no arguments |
Carbon::isLastHour
no arguments
returns bool
Checks if the instance is in the same hour as the current moment last hour.
Method added | 2.0.0 | no 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 changed | 3.2.0 | DateTimeInterface|string $date |
Prototype changed | 2.34.2 | Carbon|DateTimeInterface|string|null $date = null |
Prototype changed | 2.24.0 | \Carbon\Carbon|\DateTimeInterface|string|null $date = null |
Prototype changed | 2.0.0 | \DateTimeInterface $date = null |
Method added | 1.27.0 | $date = null |
Carbon::isCurrentMinute
no arguments
returns bool
Checks if the instance is in the same minute as the current moment.
Method added | 1.27.0 | no arguments |
Carbon::isNextMinute
no arguments
returns bool
Checks if the instance is in the same minute as the current moment next minute.
Method added | 2.0.0 | no arguments |
Carbon::isLastMinute
no arguments
returns bool
Checks if the instance is in the same minute as the current moment last minute.
Method added | 2.0.0 | no 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 changed | 3.2.0 | DateTimeInterface|string $date |
Prototype changed | 2.34.2 | Carbon|DateTimeInterface|string|null $date = null |
Prototype changed | 2.24.0 | \Carbon\Carbon|\DateTimeInterface|string|null $date = null |
Prototype changed | 2.0.0 | \DateTimeInterface $date = null |
Method added | 1.27.0 | $date = null |
Carbon::isCurrentSecond
no arguments
returns bool
Checks if the instance is in the same second as the current moment.
Method added | 1.27.0 | no arguments |
Carbon::isNextSecond
no arguments
returns bool
Checks if the instance is in the same second as the current moment next second.
Method added | 2.0.0 | no arguments |
Carbon::isLastSecond
no arguments
returns bool
Checks if the instance is in the same second as the current moment last second.
Method added | 2.0.0 | no 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 changed | 3.2.0 | DateTimeInterface|string $date |
Method added | 3.0.0 | Carbon|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 added | 3.0.0 | no arguments |
Carbon::isNextMilli
no arguments
returns bool
Checks if the instance is in the same millisecond as the current moment next millisecond.
Method added | 3.0.0 | no arguments |
Carbon::isLastMilli
no arguments
returns bool
Checks if the instance is in the same millisecond as the current moment last millisecond.
Method added | 3.0.0 | no 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 changed | 3.2.0 | DateTimeInterface|string $date |
Method added | 3.0.0 | Carbon|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 added | 3.0.0 | no arguments |
Carbon::isNextMillisecond
no arguments
returns bool
Checks if the instance is in the same millisecond as the current moment next millisecond.
Method added | 3.0.0 | no arguments |
Carbon::isLastMillisecond
no arguments
returns bool
Checks if the instance is in the same millisecond as the current moment last millisecond.
Method added | 3.0.0 | no 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 changed | 3.2.0 | DateTimeInterface|string $date |
Prototype changed | 2.34.2 | Carbon|DateTimeInterface|string|null $date = null |
Prototype changed | 2.24.0 | \Carbon\Carbon|\DateTimeInterface|string|null $date = null |
Method added | 2.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 added | 2.0.0 | no arguments |
Carbon::isNextMicro
no arguments
returns bool
Checks if the instance is in the same microsecond as the current moment next microsecond.
Method added | 2.0.0 | no arguments |
Carbon::isLastMicro
no arguments
returns bool
Checks if the instance is in the same microsecond as the current moment last microsecond.
Method added | 2.0.0 | no 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 changed | 3.2.0 | DateTimeInterface|string $date |
Prototype changed | 2.34.2 | Carbon|DateTimeInterface|string|null $date = null |
Prototype changed | 2.24.0 | \Carbon\Carbon|\DateTimeInterface|string|null $date = null |
Method added | 2.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 added | 2.0.0 | no arguments |
Carbon::isNextMicrosecond
no arguments
returns bool
Checks if the instance is in the same microsecond as the current moment next microsecond.
Method added | 2.0.0 | no arguments |
Carbon::isLastMicrosecond
no arguments
returns bool
Checks if the instance is in the same microsecond as the current moment last microsecond.
Method added | 2.0.0 | no 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 changed | 3.2.0 | DateTimeInterface|string $date |
Prototype changed | 2.34.2 | Carbon|DateTimeInterface|string|null $date = null |
Prototype changed | 2.24.0 | \Carbon\Carbon|\DateTimeInterface|string|null $date = null |
Method added | 2.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 added | 2.0.0 | no arguments |
Carbon::isNextDecade
no arguments
returns bool
Checks if the instance is in the same decade as the current moment next decade.
Method added | 2.0.0 | no arguments |
Carbon::isLastDecade
no arguments
returns bool
Checks if the instance is in the same decade as the current moment last decade.
Method added | 2.0.0 | no 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 changed | 3.2.0 | DateTimeInterface|string $date |
Prototype changed | 2.34.2 | Carbon|DateTimeInterface|string|null $date = null |
Prototype changed | 2.24.0 | \Carbon\Carbon|\DateTimeInterface|string|null $date = null |
Method added | 2.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 added | 2.0.0 | no arguments |
Carbon::isNextCentury
no arguments
returns bool
Checks if the instance is in the same century as the current moment next century.
Method added | 2.0.0 | no arguments |
Carbon::isLastCentury
no arguments
returns bool
Checks if the instance is in the same century as the current moment last century.
Method added | 2.0.0 | no 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 changed | 3.2.0 | DateTimeInterface|string $date |
Prototype changed | 2.34.2 | Carbon|DateTimeInterface|string|null $date = null |
Prototype changed | 2.24.0 | \Carbon\Carbon|\DateTimeInterface|string|null $date = null |
Method added | 2.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 added | 2.0.0 | no arguments |
Carbon::isNextMillennium
no arguments
returns bool
Checks if the instance is in the same millennium as the current moment next millennium.
Method added | 2.0.0 | no arguments |
Carbon::isLastMillennium
no arguments
returns bool
Checks if the instance is in the same millennium as the current moment last millennium.
Method added | 2.0.0 | no arguments |
Carbon::isCurrentQuarter
no arguments
returns bool
Checks if the instance is in the same quarter as the current moment.
Method added | 1.26.4 | no arguments |
Carbon::isNextQuarter
no arguments
returns bool
Checks if the instance is in the same quarter as the current moment next quarter.
Method added | 1.26.4 | no arguments |
Carbon::isLastQuarter
no arguments
returns bool
Checks if the instance is in the same quarter as the current moment last quarter.
Method added | 1.26.4 | no arguments |
Carbon::years
int $value
returns $this
Set current instance year to the given value.
Method added | 2.0.0 | int $value |
Carbon::year
int $value
returns $this
Set current instance year to the given value.
Prototype changed | 2.0.0 | int $value |
Method added | 1.0.0 | $value |
Carbon::setYears
int $value
returns $this
Set current instance year to the given value.
Method added | 2.0.0 | int $value |
Carbon::setYear
int $value
returns $this
Set current instance year to the given value.
Method added | 2.0.0 | int $value |
Carbon::months
Month|int $value
returns $this
Set current instance month to the given value.
Prototype changed | 3.0.0 | Month|int $value |
Method added | 2.0.0 | int $value |
Carbon::month
Month|int $value
returns $this
Set current instance month to the given value.
Prototype changed | 3.0.0 | Month|int $value |
Prototype changed | 2.0.0 | int $value |
Method added | 1.0.0 | $value |
Carbon::setMonths
Month|int $value
returns $this
Set current instance month to the given value.
Prototype changed | 3.0.0 | Month|int $value |
Method added | 2.0.0 | int $value |
Carbon::setMonth
Month|int $value
returns $this
Set current instance month to the given value.
Prototype changed | 3.0.0 | Month|int $value |
Method added | 2.0.0 | int $value |
Carbon::days
int $value
returns $this
Set current instance day to the given value.
Method added | 2.0.0 | int $value |
Carbon::day
int $value
returns $this
Set current instance day to the given value.
Prototype changed | 2.0.0 | int $value |
Method added | 1.0.0 | $value |
Carbon::setDays
int $value
returns $this
Set current instance day to the given value.
Method added | 2.0.0 | int $value |
Carbon::setDay
int $value
returns $this
Set current instance day to the given value.
Method added | 2.0.0 | int $value |
Carbon::hours
int $value
returns $this
Set current instance hour to the given value.
Method added | 2.0.0 | int $value |
Carbon::hour
int $value
returns $this
Set current instance hour to the given value.
Prototype changed | 2.0.0 | int $value |
Method added | 1.0.0 | $value |
Carbon::setHours
int $value
returns $this
Set current instance hour to the given value.
Method added | 2.0.0 | int $value |
Carbon::setHour
int $value
returns $this
Set current instance hour to the given value.
Method added | 2.0.0 | int $value |
Carbon::minutes
int $value
returns $this
Set current instance minute to the given value.
Method added | 2.0.0 | int $value |
Carbon::minute
int $value
returns $this
Set current instance minute to the given value.
Prototype changed | 2.0.0 | int $value |
Method added | 1.0.0 | $value |
Carbon::setMinutes
int $value
returns $this
Set current instance minute to the given value.
Method added | 2.0.0 | int $value |
Carbon::setMinute
int $value
returns $this
Set current instance minute to the given value.
Method added | 2.0.0 | int $value |
Carbon::seconds
int $value
returns $this
Set current instance second to the given value.
Method added | 2.0.0 | int $value |
Carbon::second
int $value
returns $this
Set current instance second to the given value.
Prototype changed | 2.0.0 | int $value |
Method added | 1.0.0 | $value |
Carbon::setSeconds
int $value
returns $this
Set current instance second to the given value.
Method added | 2.0.0 | int $value |
Carbon::setSecond
int $value
returns $this
Set current instance second to the given value.
Method added | 2.0.0 | int $value |
Carbon::millis
int $value
returns $this
Set current instance millisecond to the given value.
Method added | 2.7.0 | int $value |
Carbon::milli
int $value
returns $this
Set current instance millisecond to the given value.
Method added | 2.7.0 | int $value |
Carbon::setMillis
int $value
returns $this
Set current instance millisecond to the given value.
Method added | 2.7.0 | int $value |
Carbon::setMilli
int $value
returns $this
Set current instance millisecond to the given value.
Method added | 2.7.0 | int $value |
Carbon::milliseconds
int $value
returns $this
Set current instance millisecond to the given value.
Method added | 2.7.0 | int $value |
Carbon::millisecond
int $value
returns $this
Set current instance millisecond to the given value.
Method added | 2.7.0 | int $value |
Carbon::setMilliseconds
int $value
returns $this
Set current instance millisecond to the given value.
Method added | 2.7.0 | int $value |
Carbon::setMillisecond
int $value
returns $this
Set current instance millisecond to the given value.
Method added | 2.7.0 | int $value |
Carbon::micros
int $value
returns $this
Set current instance microsecond to the given value.
Method added | 2.0.0 | int $value |
Carbon::micro
int $value
returns $this
Set current instance microsecond to the given value.
Method added | 2.0.0 | int $value |
Carbon::setMicros
int $value
returns $this
Set current instance microsecond to the given value.
Method added | 2.0.0 | int $value |
Carbon::setMicro
int $value
returns $this
Set current instance microsecond to the given value.
Method added | 2.0.0 | int $value |
Carbon::microseconds
int $value
returns $this
Set current instance microsecond to the given value.
Method added | 2.0.0 | int $value |
Carbon::microsecond
int $value
returns $this
Set current instance microsecond to the given value.
Method added | 2.0.0 | int $value |
Carbon::setMicroseconds
int $value
returns $this
Set current instance microsecond to the given value.
Method added | 2.0.0 | int $value |
Carbon::setMicrosecond
int $value
returns $this
Set current instance microsecond to the given value.
Method added | 2.0.0 | int $value |
Carbon::addYears
int|float $value = 1
returns $this
Add years (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::addYear
no arguments
returns $this
Add one year to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no arguments |
Carbon::subYears
int|float $value = 1
returns $this
Sub years (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::subYear
no arguments
returns $this
Sub one year to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.24.0 | $value |
Carbon::addYearWithOverflow
no arguments
returns $this
Add one year to the instance (using date interval) with overflow explicitly allowed.
Prototype changed | 2.0.0 | no arguments |
Method added | 1.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 changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.24.0 | $value |
Carbon::subYearWithOverflow
no arguments
returns $this
Sub one year to the instance (using date interval) with overflow explicitly allowed.
Prototype changed | 2.0.0 | no arguments |
Method added | 1.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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addYearWithoutOverflow
no arguments
returns $this
Add one year to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subYearWithoutOverflow
no arguments
returns $this
Sub one year to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addYearWithNoOverflow
no arguments
returns $this
Add one year to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subYearWithNoOverflow
no arguments
returns $this
Sub one year to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.24.0 | $value |
Carbon::addYearNoOverflow
no arguments
returns $this
Add one year to the instance (using date interval) with overflow explicitly forbidden.
Prototype changed | 2.0.0 | no arguments |
Method added | 1.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 changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.24.0 | $value |
Carbon::subYearNoOverflow
no arguments
returns $this
Sub one year to the instance (using date interval) with overflow explicitly forbidden.
Prototype changed | 2.0.0 | no arguments |
Method added | 1.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 changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::addMonth
no arguments
returns $this
Add one month to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no arguments |
Carbon::subMonths
int|float $value = 1
returns $this
Sub months (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::subMonth
no arguments
returns $this
Sub one month to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.22.0 | $value |
Carbon::addMonthWithOverflow
no arguments
returns $this
Add one month to the instance (using date interval) with overflow explicitly allowed.
Prototype changed | 2.0.0 | no arguments |
Method added | 1.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 changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.22.0 | $value |
Carbon::subMonthWithOverflow
no arguments
returns $this
Sub one month to the instance (using date interval) with overflow explicitly allowed.
Prototype changed | 2.0.0 | no arguments |
Method added | 1.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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addMonthWithoutOverflow
no arguments
returns $this
Add one month to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subMonthWithoutOverflow
no arguments
returns $this
Sub one month to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addMonthWithNoOverflow
no arguments
returns $this
Add one month to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subMonthWithNoOverflow
no arguments
returns $this
Sub one month to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.14.0 | $value |
Carbon::addMonthNoOverflow
no arguments
returns $this
Add one month to the instance (using date interval) with overflow explicitly forbidden.
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.14.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.14.0 | $value |
Carbon::subMonthNoOverflow
no arguments
returns $this
Sub one month to the instance (using date interval) with overflow explicitly forbidden.
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.14.0 | no arguments |
Carbon::addDays
int|float $value = 1
returns $this
Add days (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::addDay
no arguments
returns $this
Add one day to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no arguments |
Carbon::subDays
int|float $value = 1
returns $this
Sub days (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::subDay
no arguments
returns $this
Sub one day to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no arguments |
Carbon::addHours
int|float $value = 1
returns $this
Add hours (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::addHour
no arguments
returns $this
Add one hour to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no arguments |
Carbon::subHours
int|float $value = 1
returns $this
Sub hours (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::subHour
no arguments
returns $this
Sub one hour to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no arguments |
Carbon::addMinutes
int|float $value = 1
returns $this
Add minutes (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::addMinute
no arguments
returns $this
Add one minute to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no arguments |
Carbon::subMinutes
int|float $value = 1
returns $this
Sub minutes (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::subMinute
no arguments
returns $this
Sub one minute to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no arguments |
Carbon::addSeconds
int|float $value = 1
returns $this
Add seconds (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::addSecond
no arguments
returns $this
Add one second to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no arguments |
Carbon::subSeconds
int|float $value = 1
returns $this
Sub seconds (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::subSecond
no arguments
returns $this
Sub one second to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no arguments |
Carbon::addMillis
int|float $value = 1
returns $this
Add milliseconds (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Method added | 2.6.0 | int $value = 1 |
Carbon::addMilli
no arguments
returns $this
Add one millisecond to the instance (using date interval).
Method added | 2.6.0 | no arguments |
Carbon::subMillis
int|float $value = 1
returns $this
Sub milliseconds (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Method added | 2.6.0 | int $value = 1 |
Carbon::subMilli
no arguments
returns $this
Sub one millisecond to the instance (using date interval).
Method added | 2.6.0 | no arguments |
Carbon::addMilliseconds
int|float $value = 1
returns $this
Add milliseconds (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Method added | 2.6.0 | int $value = 1 |
Carbon::addMillisecond
no arguments
returns $this
Add one millisecond to the instance (using date interval).
Method added | 2.6.0 | no arguments |
Carbon::subMilliseconds
int|float $value = 1
returns $this
Sub milliseconds (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Method added | 2.6.0 | int $value = 1 |
Carbon::subMillisecond
no arguments
returns $this
Sub one millisecond to the instance (using date interval).
Method added | 2.6.0 | no arguments |
Carbon::addMicros
int|float $value = 1
returns $this
Add microseconds (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addMicro
no arguments
returns $this
Add one microsecond to the instance (using date interval).
Method added | 2.0.0 | no arguments |
Carbon::subMicros
int|float $value = 1
returns $this
Sub microseconds (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subMicro
no arguments
returns $this
Sub one microsecond to the instance (using date interval).
Method added | 2.0.0 | no arguments |
Carbon::addMicroseconds
int|float $value = 1
returns $this
Add microseconds (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addMicrosecond
no arguments
returns $this
Add one microsecond to the instance (using date interval).
Method added | 2.0.0 | no arguments |
Carbon::subMicroseconds
int|float $value = 1
returns $this
Sub microseconds (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subMicrosecond
no arguments
returns $this
Sub one microsecond to the instance (using date interval).
Method added | 2.0.0 | no arguments |
Carbon::addMillennia
int|float $value = 1
returns $this
Add millennia (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addMillennium
no arguments
returns $this
Add one millennium to the instance (using date interval).
Method added | 2.0.0 | no arguments |
Carbon::subMillennia
int|float $value = 1
returns $this
Sub millennia (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subMillennium
no arguments
returns $this
Sub one millennium to the instance (using date interval).
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addMillenniumWithOverflow
no arguments
returns $this
Add one millennium to the instance (using date interval) with overflow explicitly allowed.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subMillenniumWithOverflow
no arguments
returns $this
Sub one millennium to the instance (using date interval) with overflow explicitly allowed.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addMillenniumWithoutOverflow
no arguments
returns $this
Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subMillenniumWithoutOverflow
no arguments
returns $this
Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addMillenniumWithNoOverflow
no arguments
returns $this
Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subMillenniumWithNoOverflow
no arguments
returns $this
Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addMillenniumNoOverflow
no arguments
returns $this
Add one millennium to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subMillenniumNoOverflow
no arguments
returns $this
Sub one millennium to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no arguments |
Carbon::addCenturies
int|float $value = 1
returns $this
Add centuries (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.22.0 | $value |
Carbon::addCentury
no arguments
returns $this
Add one century to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Method added | 1.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 changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.22.0 | $value |
Carbon::subCentury
no arguments
returns $this
Sub one century to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Method added | 1.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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addCenturyWithOverflow
no arguments
returns $this
Add one century to the instance (using date interval) with overflow explicitly allowed.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subCenturyWithOverflow
no arguments
returns $this
Sub one century to the instance (using date interval) with overflow explicitly allowed.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addCenturyWithoutOverflow
no arguments
returns $this
Add one century to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subCenturyWithoutOverflow
no arguments
returns $this
Sub one century to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addCenturyWithNoOverflow
no arguments
returns $this
Add one century to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subCenturyWithNoOverflow
no arguments
returns $this
Sub one century to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addCenturyNoOverflow
no arguments
returns $this
Add one century to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subCenturyNoOverflow
no arguments
returns $this
Sub one century to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no arguments |
Carbon::addDecades
int|float $value = 1
returns $this
Add decades (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addDecade
no arguments
returns $this
Add one decade to the instance (using date interval).
Method added | 2.0.0 | no arguments |
Carbon::subDecades
int|float $value = 1
returns $this
Sub decades (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subDecade
no arguments
returns $this
Sub one decade to the instance (using date interval).
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addDecadeWithOverflow
no arguments
returns $this
Add one decade to the instance (using date interval) with overflow explicitly allowed.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subDecadeWithOverflow
no arguments
returns $this
Sub one decade to the instance (using date interval) with overflow explicitly allowed.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addDecadeWithoutOverflow
no arguments
returns $this
Add one decade to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subDecadeWithoutOverflow
no arguments
returns $this
Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addDecadeWithNoOverflow
no arguments
returns $this
Add one decade to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subDecadeWithNoOverflow
no arguments
returns $this
Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addDecadeNoOverflow
no arguments
returns $this
Add one decade to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subDecadeNoOverflow
no arguments
returns $this
Sub one decade to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no arguments |
Carbon::addQuarters
int|float $value = 1
returns $this
Add quarters (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.22.0 | $value |
Carbon::addQuarter
no arguments
returns $this
Add one quarter to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Method added | 1.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 changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.22.0 | $value |
Carbon::subQuarter
no arguments
returns $this
Sub one quarter to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Method added | 1.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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addQuarterWithOverflow
no arguments
returns $this
Add one quarter to the instance (using date interval) with overflow explicitly allowed.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subQuarterWithOverflow
no arguments
returns $this
Sub one quarter to the instance (using date interval) with overflow explicitly allowed.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addQuarterWithoutOverflow
no arguments
returns $this
Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subQuarterWithoutOverflow
no arguments
returns $this
Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addQuarterWithNoOverflow
no arguments
returns $this
Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subQuarterWithNoOverflow
no arguments
returns $this
Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::addQuarterNoOverflow
no arguments
returns $this
Add one quarter to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no 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 changed | 3.0.0 | int|float $value = 1 |
Method added | 2.0.0 | int $value = 1 |
Carbon::subQuarterNoOverflow
no arguments
returns $this
Sub one quarter to the instance (using date interval) with overflow explicitly forbidden.
Method added | 2.0.0 | no arguments |
Carbon::addWeeks
int|float $value = 1
returns $this
Add weeks (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::addWeek
no arguments
returns $this
Add one week to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no arguments |
Carbon::subWeeks
int|float $value = 1
returns $this
Sub weeks (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::subWeek
no arguments
returns $this
Sub one week to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no arguments |
Carbon::addWeekdays
int|float $value = 1
returns $this
Add weekdays (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::addWeekday
no arguments
returns $this
Add one weekday to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no arguments |
Carbon::subWeekdays
int|float $value = 1
returns $this
Sub weekdays (the $value count passed in) to the instance (using date interval).
Prototype changed | 3.0.0 | int|float $value = 1 |
Prototype changed | 2.0.0 | int $value = 1 |
Method added | 1.0.0 | $value |
Carbon::subWeekday
no arguments
returns $this
Sub one weekday to the instance (using date interval).
Prototype changed | 2.0.0 | no arguments |
Prototype changed | 1.18.0 | $value = 1 |
Method added | 1.0.0 | no arguments |
Carbon::addUTCMicros
int|float $value = 1
returns $this
Add microseconds (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCMicro
no arguments
returns $this
Add one microsecond to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCMicros
int|float $value = 1
returns $this
Sub microseconds (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCMicro
no arguments
returns $this
Sub one microsecond to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCMicrosecond
no arguments
returns $this
Add one microsecond to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCMicroseconds
int|float $value = 1
returns $this
Sub microseconds (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCMicrosecond
no arguments
returns $this
Sub one microsecond to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCMilli
no arguments
returns $this
Add one millisecond to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCMillis
int|float $value = 1
returns $this
Sub milliseconds (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCMilli
no arguments
returns $this
Sub one millisecond to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCMillisecond
no arguments
returns $this
Add one millisecond to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCMilliseconds
int|float $value = 1
returns $this
Sub milliseconds (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCMillisecond
no arguments
returns $this
Sub one millisecond to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCSecond
no arguments
returns $this
Add one second to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCSeconds
int|float $value = 1
returns $this
Sub seconds (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCSecond
no arguments
returns $this
Sub one second to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCMinute
no arguments
returns $this
Add one minute to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCMinutes
int|float $value = 1
returns $this
Sub minutes (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCMinute
no arguments
returns $this
Sub one minute to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCHour
no arguments
returns $this
Add one hour to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCHours
int|float $value = 1
returns $this
Sub hours (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCHour
no arguments
returns $this
Sub one hour to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCDay
no arguments
returns $this
Add one day to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCDays
int|float $value = 1
returns $this
Sub days (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCDay
no arguments
returns $this
Sub one day to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCWeek
no arguments
returns $this
Add one week to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCWeeks
int|float $value = 1
returns $this
Sub weeks (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCWeek
no arguments
returns $this
Sub one week to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCMonth
no arguments
returns $this
Add one month to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCMonths
int|float $value = 1
returns $this
Sub months (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCMonth
no arguments
returns $this
Sub one month to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCQuarter
no arguments
returns $this
Add one quarter to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCQuarters
int|float $value = 1
returns $this
Sub quarters (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCQuarter
no arguments
returns $this
Sub one quarter to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCYear
no arguments
returns $this
Add one year to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCYears
int|float $value = 1
returns $this
Sub years (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCYear
no arguments
returns $this
Sub one year to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCDecade
no arguments
returns $this
Add one decade to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCDecades
int|float $value = 1
returns $this
Sub decades (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCDecade
no arguments
returns $this
Sub one decade to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCCentury
no arguments
returns $this
Add one century to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCCenturies
int|float $value = 1
returns $this
Sub centuries (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCCentury
no arguments
returns $this
Sub one century to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 3.2.0 | int|float $value = 1 |
Carbon::addUTCMillennium
no arguments
returns $this
Add one millennium to the instance (using timestamp).
Method added | 3.2.0 | no arguments |
Carbon::subUTCMillennia
int|float $value = 1
returns $this
Sub millennia (the $value count passed in) to the instance (using timestamp).
Method added | 3.2.0 | int|float $value = 1 |
Carbon::subUTCMillennium
no arguments
returns $this
Sub one millennium to the instance (using timestamp).
Method added | 3.2.0 | no 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 changed | 3.0.0 | $endDate = null, int|float $factor = 1 |
Method added | 2.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 added | 3.2.0 | DateTimeInterface|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 added | 2.0.0 | float $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 added | 2.0.0 | float $precision = 1, string $function = "round" |
Carbon::floorYear
float $precision = 1
returns $this
Truncate the current instance year with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::floorYears
float $precision = 1
returns $this
Truncate the current instance year with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilYear
float $precision = 1
returns $this
Ceil the current instance year with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilYears
float $precision = 1
returns $this
Ceil the current instance year with given precision.
Method added | 2.0.0 | float $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 added | 2.0.0 | float $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 added | 2.0.0 | float $precision = 1, string $function = "round" |
Carbon::floorMonth
float $precision = 1
returns $this
Truncate the current instance month with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::floorMonths
float $precision = 1
returns $this
Truncate the current instance month with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilMonth
float $precision = 1
returns $this
Ceil the current instance month with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilMonths
float $precision = 1
returns $this
Ceil the current instance month with given precision.
Method added | 2.0.0 | float $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 added | 2.0.0 | float $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 added | 2.0.0 | float $precision = 1, string $function = "round" |
Carbon::floorDay
float $precision = 1
returns $this
Truncate the current instance day with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::floorDays
float $precision = 1
returns $this
Truncate the current instance day with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilDay
float $precision = 1
returns $this
Ceil the current instance day with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilDays
float $precision = 1
returns $this
Ceil the current instance day with given precision.
Method added | 2.0.0 | float $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 added | 2.0.0 | float $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 added | 2.0.0 | float $precision = 1, string $function = "round" |
Carbon::floorHour
float $precision = 1
returns $this
Truncate the current instance hour with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::floorHours
float $precision = 1
returns $this
Truncate the current instance hour with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilHour
float $precision = 1
returns $this
Ceil the current instance hour with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilHours
float $precision = 1
returns $this
Ceil the current instance hour with given precision.
Method added | 2.0.0 | float $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 added | 2.0.0 | float $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 added | 2.0.0 | float $precision = 1, string $function = "round" |
Carbon::floorMinute
float $precision = 1
returns $this
Truncate the current instance minute with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::floorMinutes
float $precision = 1
returns $this
Truncate the current instance minute with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilMinute
float $precision = 1
returns $this
Ceil the current instance minute with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilMinutes
float $precision = 1
returns $this
Ceil the current instance minute with given precision.
Method added | 2.0.0 | float $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 added | 2.0.0 | float $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 added | 2.0.0 | float $precision = 1, string $function = "round" |
Carbon::floorSecond
float $precision = 1
returns $this
Truncate the current instance second with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::floorSeconds
float $precision = 1
returns $this
Truncate the current instance second with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilSecond
float $precision = 1
returns $this
Ceil the current instance second with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilSeconds
float $precision = 1
returns $this
Ceil the current instance second with given precision.
Method added | 2.0.0 | float $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 added | 2.0.0 | float $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 added | 2.0.0 | float $precision = 1, string $function = "round" |
Carbon::floorMillennium
float $precision = 1
returns $this
Truncate the current instance millennium with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::floorMillennia
float $precision = 1
returns $this
Truncate the current instance millennium with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilMillennium
float $precision = 1
returns $this
Ceil the current instance millennium with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilMillennia
float $precision = 1
returns $this
Ceil the current instance millennium with given precision.
Method added | 2.0.0 | float $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 added | 2.0.0 | float $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 added | 2.0.0 | float $precision = 1, string $function = "round" |
Carbon::floorCentury
float $precision = 1
returns $this
Truncate the current instance century with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::floorCenturies
float $precision = 1
returns $this
Truncate the current instance century with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilCentury
float $precision = 1
returns $this
Ceil the current instance century with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilCenturies
float $precision = 1
returns $this
Ceil the current instance century with given precision.
Method added | 2.0.0 | float $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 added | 2.0.0 | float $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 added | 2.0.0 | float $precision = 1, string $function = "round" |
Carbon::floorDecade
float $precision = 1
returns $this
Truncate the current instance decade with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::floorDecades
float $precision = 1
returns $this
Truncate the current instance decade with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilDecade
float $precision = 1
returns $this
Ceil the current instance decade with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilDecades
float $precision = 1
returns $this
Ceil the current instance decade with given precision.
Method added | 2.0.0 | float $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 added | 2.0.0 | float $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 added | 2.0.0 | float $precision = 1, string $function = "round" |
Carbon::floorQuarter
float $precision = 1
returns $this
Truncate the current instance quarter with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::floorQuarters
float $precision = 1
returns $this
Truncate the current instance quarter with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilQuarter
float $precision = 1
returns $this
Ceil the current instance quarter with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilQuarters
float $precision = 1
returns $this
Ceil the current instance quarter with given precision.
Method added | 2.0.0 | float $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 added | 2.0.0 | float $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 added | 2.0.0 | float $precision = 1, string $function = "round" |
Carbon::floorMillisecond
float $precision = 1
returns $this
Truncate the current instance millisecond with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::floorMilliseconds
float $precision = 1
returns $this
Truncate the current instance millisecond with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilMillisecond
float $precision = 1
returns $this
Ceil the current instance millisecond with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilMilliseconds
float $precision = 1
returns $this
Ceil the current instance millisecond with given precision.
Method added | 2.0.0 | float $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 added | 2.0.0 | float $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 added | 2.0.0 | float $precision = 1, string $function = "round" |
Carbon::floorMicrosecond
float $precision = 1
returns $this
Truncate the current instance microsecond with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::floorMicroseconds
float $precision = 1
returns $this
Truncate the current instance microsecond with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilMicrosecond
float $precision = 1
returns $this
Ceil the current instance microsecond with given precision.
Method added | 2.0.0 | float $precision = 1 |
Carbon::ceilMicroseconds
float $precision = 1
returns $this
Ceil the current instance microsecond with given precision.
Method added | 2.0.0 | float $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 changed | 2.34.2 | DateTimeInterface $other = null, int $parts = 1 |
Method added | 2.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 changed | 2.34.2 | DateTimeInterface $other = null, int $parts = 1 |
Method added | 2.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 changed | 2.34.2 | DateTimeInterface $other = null, int $parts = 1 |
Method added | 2.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 changed | 2.34.2 | DateTimeInterface $other = null, int $parts = 1 |
Method added | 2.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 changed | 2.34.2 | DateTimeInterface $other = null, int $parts = 1 |
Method added | 2.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 changed | 2.34.2 | DateTimeInterface $other = null, int $parts = 1 |
Method added | 2.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 changed | 2.34.2 | DateTimeInterface $other = null, int $parts = 1 |
Method added | 2.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 changed | 2.34.2 | DateTimeInterface $other = null, int $parts = 1 |
Method added | 2.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 added | 3.0.0 | no 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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.0.0 | ?int $day = null |
Carbon::daysInCentury
no arguments
returns int
Return the number of days contained in the current century
Method added | 3.0.0 | no arguments |
Carbon::daysInDecade
no arguments
returns int
Return the number of days contained in the current decade
Method added | 3.0.0 | no arguments |
Carbon::daysInMillennium
no arguments
returns int
Return the number of days contained in the current millennium
Method added | 3.0.0 | no arguments |
Carbon::daysInMonth
no arguments
returns int
Return the number of days contained in the current month
Method added | 3.0.0 | no arguments |
Carbon::daysInQuarter
no arguments
returns int
Return the number of days contained in the current quarter
Method added | 3.0.0 | no arguments |
Carbon::daysInWeek
no arguments
returns int
Return the number of days contained in the current week
Method added | 3.0.0 | no arguments |
Carbon::daysInYear
no arguments
returns int
Return the number of days contained in the current year
Method added | 3.0.0 | no 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 added | 3.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 added | 3.0.0 | ?int $decade = null |
Carbon::decadesInCentury
no arguments
returns int
Return the number of decades contained in the current century
Method added | 3.0.0 | no arguments |
Carbon::decadesInMillennium
no arguments
returns int
Return the number of decades contained in the current millennium
Method added | 3.0.0 | no 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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.0.0 | ?int $hour = null |
Carbon::hoursInCentury
no arguments
returns int
Return the number of hours contained in the current century
Method added | 3.0.0 | no arguments |
Carbon::hoursInDay
no arguments
returns int
Return the number of hours contained in the current day
Method added | 3.0.0 | no arguments |
Carbon::hoursInDecade
no arguments
returns int
Return the number of hours contained in the current decade
Method added | 3.0.0 | no arguments |
Carbon::hoursInMillennium
no arguments
returns int
Return the number of hours contained in the current millennium
Method added | 3.0.0 | no arguments |
Carbon::hoursInMonth
no arguments
returns int
Return the number of hours contained in the current month
Method added | 3.0.0 | no arguments |
Carbon::hoursInQuarter
no arguments
returns int
Return the number of hours contained in the current quarter
Method added | 3.0.0 | no arguments |
Carbon::hoursInWeek
no arguments
returns int
Return the number of hours contained in the current week
Method added | 3.0.0 | no arguments |
Carbon::hoursInYear
no arguments
returns int
Return the number of hours contained in the current year
Method added | 3.0.0 | no 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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.0.0 | ?int $microsecond = null |
Carbon::microsecondsInCentury
no arguments
returns int
Return the number of microseconds contained in the current century
Method added | 3.0.0 | no arguments |
Carbon::microsecondsInDay
no arguments
returns int
Return the number of microseconds contained in the current day
Method added | 3.0.0 | no arguments |
Carbon::microsecondsInDecade
no arguments
returns int
Return the number of microseconds contained in the current decade
Method added | 3.0.0 | no arguments |
Carbon::microsecondsInHour
no arguments
returns int
Return the number of microseconds contained in the current hour
Method added | 3.0.0 | no arguments |
Carbon::microsecondsInMillennium
no arguments
returns int
Return the number of microseconds contained in the current millennium
Method added | 3.0.0 | no arguments |
Carbon::microsecondsInMillisecond
no arguments
returns int
Return the number of microseconds contained in the current millisecond
Method added | 3.0.0 | no arguments |
Carbon::microsecondsInMinute
no arguments
returns int
Return the number of microseconds contained in the current minute
Method added | 3.0.0 | no arguments |
Carbon::microsecondsInMonth
no arguments
returns int
Return the number of microseconds contained in the current month
Method added | 3.0.0 | no arguments |
Carbon::microsecondsInQuarter
no arguments
returns int
Return the number of microseconds contained in the current quarter
Method added | 3.0.0 | no arguments |
Carbon::microsecondsInSecond
no arguments
returns int
Return the number of microseconds contained in the current second
Method added | 3.0.0 | no arguments |
Carbon::microsecondsInWeek
no arguments
returns int
Return the number of microseconds contained in the current week
Method added | 3.0.0 | no arguments |
Carbon::microsecondsInYear
no arguments
returns int
Return the number of microseconds contained in the current year
Method added | 3.0.0 | no 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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.0.0 | ?int $millisecond = null |
Carbon::millisecondsInCentury
no arguments
returns int
Return the number of milliseconds contained in the current century
Method added | 3.0.0 | no arguments |
Carbon::millisecondsInDay
no arguments
returns int
Return the number of milliseconds contained in the current day
Method added | 3.0.0 | no arguments |
Carbon::millisecondsInDecade
no arguments
returns int
Return the number of milliseconds contained in the current decade
Method added | 3.0.0 | no arguments |
Carbon::millisecondsInHour
no arguments
returns int
Return the number of milliseconds contained in the current hour
Method added | 3.0.0 | no arguments |
Carbon::millisecondsInMillennium
no arguments
returns int
Return the number of milliseconds contained in the current millennium
Method added | 3.0.0 | no arguments |
Carbon::millisecondsInMinute
no arguments
returns int
Return the number of milliseconds contained in the current minute
Method added | 3.0.0 | no arguments |
Carbon::millisecondsInMonth
no arguments
returns int
Return the number of milliseconds contained in the current month
Method added | 3.0.0 | no arguments |
Carbon::millisecondsInQuarter
no arguments
returns int
Return the number of milliseconds contained in the current quarter
Method added | 3.0.0 | no arguments |
Carbon::millisecondsInSecond
no arguments
returns int
Return the number of milliseconds contained in the current second
Method added | 3.0.0 | no arguments |
Carbon::millisecondsInWeek
no arguments
returns int
Return the number of milliseconds contained in the current week
Method added | 3.0.0 | no arguments |
Carbon::millisecondsInYear
no arguments
returns int
Return the number of milliseconds contained in the current year
Method added | 3.0.0 | no 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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.0.0 | ?int $minute = null |
Carbon::minutesInCentury
no arguments
returns int
Return the number of minutes contained in the current century
Method added | 3.0.0 | no arguments |
Carbon::minutesInDay
no arguments
returns int
Return the number of minutes contained in the current day
Method added | 3.0.0 | no arguments |
Carbon::minutesInDecade
no arguments
returns int
Return the number of minutes contained in the current decade
Method added | 3.0.0 | no arguments |
Carbon::minutesInHour
no arguments
returns int
Return the number of minutes contained in the current hour
Method added | 3.0.0 | no arguments |
Carbon::minutesInMillennium
no arguments
returns int
Return the number of minutes contained in the current millennium
Method added | 3.0.0 | no arguments |
Carbon::minutesInMonth
no arguments
returns int
Return the number of minutes contained in the current month
Method added | 3.0.0 | no arguments |
Carbon::minutesInQuarter
no arguments
returns int
Return the number of minutes contained in the current quarter
Method added | 3.0.0 | no arguments |
Carbon::minutesInWeek
no arguments
returns int
Return the number of minutes contained in the current week
Method added | 3.0.0 | no arguments |
Carbon::minutesInYear
no arguments
returns int
Return the number of minutes contained in the current year
Method added | 3.0.0 | no 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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.0.0 | ?int $month = null |
Carbon::monthsInCentury
no arguments
returns int
Return the number of months contained in the current century
Method added | 3.0.0 | no arguments |
Carbon::monthsInDecade
no arguments
returns int
Return the number of months contained in the current decade
Method added | 3.0.0 | no arguments |
Carbon::monthsInMillennium
no arguments
returns int
Return the number of months contained in the current millennium
Method added | 3.0.0 | no arguments |
Carbon::monthsInQuarter
no arguments
returns int
Return the number of months contained in the current quarter
Method added | 3.0.0 | no arguments |
Carbon::monthsInYear
no arguments
returns int
Return the number of months contained in the current year
Method added | 3.0.0 | no 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 added | 3.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 added | 3.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 added | 3.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 added | 3.0.0 | ?int $quarter = null |
Carbon::quartersInCentury
no arguments
returns int
Return the number of quarters contained in the current century
Method added | 3.0.0 | no arguments |
Carbon::quartersInDecade
no arguments
returns int
Return the number of quarters contained in the current decade
Method added | 3.0.0 | no arguments |
Carbon::quartersInMillennium
no arguments
returns int
Return the number of quarters contained in the current millennium
Method added | 3.0.0 | no arguments |
Carbon::quartersInYear
no arguments
returns int
Return the number of quarters contained in the current year
Method added | 3.0.0 | no 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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.0.0 | ?int $second = null |
Carbon::secondsInCentury
no arguments
returns int
Return the number of seconds contained in the current century
Method added | 3.0.0 | no arguments |
Carbon::secondsInDay
no arguments
returns int
Return the number of seconds contained in the current day
Method added | 3.0.0 | no arguments |
Carbon::secondsInDecade
no arguments
returns int
Return the number of seconds contained in the current decade
Method added | 3.0.0 | no arguments |
Carbon::secondsInHour
no arguments
returns int
Return the number of seconds contained in the current hour
Method added | 3.0.0 | no arguments |
Carbon::secondsInMillennium
no arguments
returns int
Return the number of seconds contained in the current millennium
Method added | 3.0.0 | no arguments |
Carbon::secondsInMinute
no arguments
returns int
Return the number of seconds contained in the current minute
Method added | 3.0.0 | no arguments |
Carbon::secondsInMonth
no arguments
returns int
Return the number of seconds contained in the current month
Method added | 3.0.0 | no arguments |
Carbon::secondsInQuarter
no arguments
returns int
Return the number of seconds contained in the current quarter
Method added | 3.0.0 | no arguments |
Carbon::secondsInWeek
no arguments
returns int
Return the number of seconds contained in the current week
Method added | 3.0.0 | no arguments |
Carbon::secondsInYear
no arguments
returns int
Return the number of seconds contained in the current year
Method added | 3.0.0 | no 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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.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 added | 3.0.0 | ?int $week = null |
Carbon::weeksInCentury
no arguments
returns int
Return the number of weeks contained in the current century
Method added | 3.0.0 | no arguments |
Carbon::weeksInDecade
no arguments
returns int
Return the number of weeks contained in the current decade
Method added | 3.0.0 | no arguments |
Carbon::weeksInMillennium
no arguments
returns int
Return the number of weeks contained in the current millennium
Method added | 3.0.0 | no arguments |
Carbon::weeksInMonth
no arguments
returns int
Return the number of weeks contained in the current month
Method added | 3.0.0 | no arguments |
Carbon::weeksInQuarter
no arguments
returns int
Return the number of weeks contained in the current quarter
Method added | 3.0.0 | no 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 added | 3.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 added | 3.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 added | 3.0.0 | ?int $year = null |
Carbon::yearsInCentury
no arguments
returns int
Return the number of years contained in the current century
Method added | 3.0.0 | no arguments |
Carbon::yearsInDecade
no arguments
returns int
Return the number of years contained in the current decade
Method added | 3.0.0 | no arguments |
Carbon::yearsInMillennium
no arguments
returns int
Return the number of years contained in the current millennium
Method added | 3.0.0 | no arguments |