boolReturns true if the current class/instance is mutable.
| Method added | 2.0.0 | no arguments |
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 |
arrayReturns the values to dump on serialize() called on.
Only used by PHP >= 7.4.
| Method added | 1.21.0 | no arguments |
array $data
Set locale if specified on unserialize() called.
Only used by PHP >= 7.4.
| Method added | 1.21.0 | array $data |
Set locale if specified on unserialize() called.
Only used by PHP < 7.4.
| Method added | 1.0.0 | no arguments |
$dump
CarbonThe __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 |
DateTime$format, $time, $timezone = null
CarbonCreate a Carbon instance from a specific format.
| Prototype changed | 3.0.0 | $format, $time, $timezone = null |
| Prototype changed | 1.3.0 | $format, $time, $tz = null |
| Method added | 1.0.0 | $format, $time, $object = null |
array|false{@inheritdoc}
| Method added | 1.0.0 | no arguments |
string $format
stringReturns the formatted date string on success or FALSE on failure.
| Prototype changed | 3.0.0 | string $format |
| Prototype changed | 2.16.0 | $format |
| Prototype changed | 1.21.0 | string $format |
| Method added | 1.0.0 | $format |
$modify
CarbonCalls \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 |
$unit, $value = 1, ?bool $overflow = null
CarbonAdd 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 |
$unit, $value = 1, ?bool $overflow = null
CarbonSubtract 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 |
CarbonTimeZoneGet the TimeZone associated with the Carbon instance (as CarbonTimeZone).
| Method added | 1.0.0 | no arguments |
DateTimeZone|string|int $timeZone
CarbonSet the instance's timezone from a string or object.
| Prototype changed | 3.0.0 | DateTimeZone|string|int $timeZone |
| Method added | 1.0.0 | $value |
int $hour, int $minute, int $second = 0, int $microseconds = 0
CarbonResets 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 |
int $year, int $month, int $day
CarbonSet 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 |
int $year, int $week, int $day = 1
CarbonSet 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 |
string|int|float $timestamp
CarbonSet 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 |
$date = null, bool $absolute = false, array $skip = []
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 |
CarbonGet a copy of the instance.
| Method added | 1.0.0 | no arguments |
Carbon@alias copy
Get a copy of the instance.
| Method added | 2.0.0 | no arguments |
CarbonClone 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 |
CarbonReturns a present instance in the same timezone.
| Method added | 1.24.0 | no arguments |
$date = null
CarbonReturn 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 |
string $name
mixedGet a part of the Carbon object.
| Prototype changed | 3.0.0 | string $name |
| Method added | 1.0.0 | $name |
Carbon\Unit|string $name
mixedGet 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 |
$name
boolCheck if an attribute exists on the object
| Method added | 1.2.0 | $name |
$name, $value
Set a part of the Carbon object
| Method added | 1.0.0 | $name, $value |
Carbon\Unit|array|string $name, DateTimeZone|Carbon\Month|string|int|float|null $value = null
CarbonSet 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 |
?string $context = null, string $keySuffix = '', ?string $defaultValue = null
stringGet 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 |
?string $context = null
stringGet 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 |
?string $context = null
stringGet 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 |
?string $context = null, string $keySuffix = '', ?string $defaultValue = null
stringGet 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 |
?string $context = null
stringGet 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 |
?int $value = null
Carbon|intGet/set the day of year.
| Prototype changed | 3.0.0 | ?int $value = null |
| Method added | 2.0.0 | $value = null |
Carbon\WeekDay|int|null $value = null
Carbon|intGet/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\WeekDay|int|null $value = null
Carbon|intGet/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\WeekDay|int|null $weekStartsAt = null
intReturn 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 |
int $numberOfDays, Carbon\WeekDay|int|null $weekStartsAt = null
CarbonSet 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 |
string $valueUnit, int $value, string $overflowUnit
CarbonSet 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 |
string $valueUnit, int $value, string $overflowUnit
CarbonAdd 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 |
string $valueUnit, int $value, string $overflowUnit
CarbonSubtract 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 |
?int $minuteOffset = null
Carbon|intReturns 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 |
int $year, int $month, int $day, int $hour, int $minute, int $second = 0, int $microseconds = 0
CarbonSet 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 |
string $time
CarbonSet the time by time string.
| Prototype changed | 3.0.0 | string $time |
| Method added | 1.21.0 | $time |
DateTimeZone|string|int $value
Carbon@alias setTimezone
| Prototype changed | 3.0.0 | DateTimeZone|string|int $value |
| Method added | 1.0.0 | $value |
DateTimeZone|string|int|null $value = null
Carbon|stringSet 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 |
DateTimeZone|string $value
CarbonSet 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 |
CarbonSet the instance's timezone to UTC.
| Method added | 2.0.0 | no arguments |
DateTimeInterface|string $date
CarbonSet 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 |
DateTimeInterface|string $date
CarbonSet 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 |
DateTimeInterface|string $date
CarbonSet 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 |
arrayGet the days of the week.
| Method added | 1.23.0 | no arguments |
?string $locale = null
intGet the first day of week.
| Prototype changed | 3.0.0 | ?string $locale = null |
| Method added | 1.20.0 | no arguments |
?string $locale = null
intGet the last day of week.
| Prototype changed | 3.0.0 | ?string $locale = null |
| Method added | 1.20.0 | no arguments |
arrayGet weekend days
| Method added | 1.20.0 | no arguments |
array $days
Examples:
Carbon::macro('isDayOff', function ($date) {
return $date->isSunday() || $date->isMonday();
});
Carbon::macro('isNotDayOff', function ($date) {
return !$date->isDayOff();
});
if ($someDate->isDayOff()) ...
if ($someDate->isNotDayOff()) ...
// Add 5 not-off days
$count = 5;
while ($someDate->isDayOff() || ($count-- > 0)) {
$someDate->addDay();
}
| Prototype changed | 3.0.0 | array $days |
| Method added | 1.20.0 | $days |
?string $time
boolDetermine if a time string will produce a relative date.
| Prototype changed | 3.0.0 | ?string $time |
| Method added | 1.4.0 | $time |
?string $locale = null
arrayReturns list of locale formats for ISO formatting.
| Prototype changed | 3.0.0 | ?string $locale = null |
| Method added | 2.0.0 | $locale = null |
?string $locale = null
arrayReturns list of calendar formats for ISO formatting.
| Prototype changed | 3.0.0 | ?string $locale = null |
| Method added | 2.0.0 | $locale = null |
arrayReturns list of locale units for ISO formatting.
| Method added | 2.0.0 | no arguments |
$unit, $length = 2, $padString = '0', $padType = 0
stringReturns 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 |
string $key, ?string $period = null
stringReturn a property with its ordinal.
| Method added | 2.0.0 | string $key, ?string $period = null |
bool $isLower = false
stringReturn the meridiem of the current time in the current locale.
| Method added | 2.14.0 | bool $isLower = false |
string $key
stringReturns the alternative number for a given date property if available in the current locale.
| Method added | 2.14.0 | string $key |
string $format, ?string $originalFormat = null
stringFormat in the current language using ISO replacement patterns.
| Prototype changed | 2.16.0 | string $format, ?string $originalFormat = null |
| Method added | 2.0.0 | string $format |
arrayList of replacements from date() format to isoFormat().
| Method added | 2.16.0 | no arguments |
string $format
stringFormat as ->format() do (using date replacements patterns from https://php.net/manual/en/function.date.php) but translate words whenever possible (months, day names, etc.) using the current locale.
| Method added | 2.16.0 | string $format |
string $separator = ':'
stringReturns 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 = ':' |
string $unit, Carbon\Month|int|float|null $value = null
CarbonSet 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 |
string $unit
stringReturns standardized singular of a given singular/plural unit name (in English).
| Method added | 2.0.0 | string $unit |
string $unit
stringReturns standardized plural of a given singular/plural unit name (in English).
| Method added | 2.0.0 | string $unit |
int|float $seconds
| Method added | 3.0.0 | int|float $seconds |
CarbonResets 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 |
CarbonResets 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 |
CarbonResets 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 |
CarbonResets 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 |
CarbonResets 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 |
CarbonResets 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 |
CarbonResets 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 |
CarbonResets 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 |
CarbonResets 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 |
CarbonResets 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 |
CarbonResets 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 |
CarbonResets 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 |
CarbonResets 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 |
CarbonResets 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\WeekDay|int|null $weekStartsAt = null
CarbonResets 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\WeekDay|int|null $weekEndsAt = null
CarbonResets 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 |
CarbonModify 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 |
CarbonModify 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 |
CarbonModify 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 |
CarbonModify 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 |
CarbonModify 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 |
CarbonModify 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 |
CarbonModify 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 |
CarbonModify 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\Unit|string $unit, mixed $params
CarbonModify 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\Unit|string $unit, mixed $params
CarbonModify 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 |
DateTimeInterface|string $date
boolDetermines if the instance is equal to another
Examples:
Carbon::parse('2018-07-25 12:45:16')->eq('2018-07-25 12:45:16'); // true
Carbon::parse('2018-07-25 12:45:16')->eq(Carbon::parse('2018-07-25 12:45:16')); // true
Carbon::parse('2018-07-25 12:45:16')->eq('2018-07-25 12:45:17'); // false
| Prototype 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 |
DateTimeInterface|string $date
boolDetermines if the instance is equal to another
Examples:
Carbon::parse('2018-07-25 12:45:16')->equalTo('2018-07-25 12:45:16'); // true
Carbon::parse('2018-07-25 12:45:16')->equalTo(Carbon::parse('2018-07-25 12:45:16')); // true
Carbon::parse('2018-07-25 12:45:16')->equalTo('2018-07-25 12:45:17'); // false
| Prototype 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 |
DateTimeInterface|string $date
boolDetermines if the instance is not equal to another
Examples:
Carbon::parse('2018-07-25 12:45:16')->ne('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->ne(Carbon::parse('2018-07-25 12:45:16')); // false
Carbon::parse('2018-07-25 12:45:16')->ne('2018-07-25 12:45:17'); // true
| Prototype 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 |
DateTimeInterface|string $date
boolDetermines if the instance is not equal to another
Examples:
Carbon::parse('2018-07-25 12:45:16')->notEqualTo('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->notEqualTo(Carbon::parse('2018-07-25 12:45:16')); // false
Carbon::parse('2018-07-25 12:45:16')->notEqualTo('2018-07-25 12:45:17'); // true
| Prototype 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 |
DateTimeInterface|string $date
boolDetermines if the instance is greater (after) than another
Examples:
Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:15'); // true
Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:17'); // false
| Prototype 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 |
DateTimeInterface|string $date
boolDetermines if the instance is greater (after) than another
Examples:
Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:15'); // true
Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:17'); // false
| Prototype 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 |
DateTimeInterface|string $date
boolDetermines if the instance is greater (after) than another
Examples:
Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:15'); // true
Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:17'); // false
| Prototype changed | 3.0.0 | DateTimeInterface|string $date |
| Method added | 1.39.0 | $date |
DateTimeInterface|string $date
boolDetermines if the instance is greater (after) than or equal to another
Examples:
Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:15'); // true
Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:16'); // true
Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:17'); // false
| Prototype 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 |
DateTimeInterface|string $date
boolDetermines if the instance is greater (after) than or equal to another
Examples:
Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:15'); // true
Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:16'); // true
Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:17'); // false
| Prototype 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 |
DateTimeInterface|string $date
boolDetermines if the instance is less (before) than another
Examples:
Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:15'); // false
Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:17'); // true
| Prototype 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 |
DateTimeInterface|string $date
boolDetermines if the instance is less (before) than another
Examples:
Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:15'); // false
Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:17'); // true
| Prototype 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 |
DateTimeInterface|string $date
boolDetermines if the instance is less (before) than another
Examples:
Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:15'); // false
Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:16'); // false
Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:17'); // true
| Prototype changed | 3.0.0 | DateTimeInterface|string $date |
| Method added | 1.39.0 | $date |
DateTimeInterface|string $date
boolDetermines if the instance is less (before) or equal to another
Examples:
Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:15'); // false
Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:16'); // true
Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:17'); // true
| Prototype 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 |
DateTimeInterface|string $date
boolDetermines if the instance is less (before) or equal to another
Examples:
Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:15'); // false
Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:16'); // true
Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:17'); // true
| Prototype 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 |
DateTimeInterface|string $date1, DateTimeInterface|string $date2, bool $equal = true
boolDetermines if the instance is between two others.
The third argument allow you to specify if bounds are included or not (true by default)
but for when you including/excluding bounds may produce different results in your application,
we recommend to use the explicit methods ->betweenIncluded() or ->betweenExcluded() instead.
Examples:
Carbon::parse('2018-07-25')->between('2018-07-14', '2018-08-01'); // true
Carbon::parse('2018-07-25')->between('2018-08-01', '2018-08-20'); // false
Carbon::parse('2018-07-25')->between('2018-07-25', '2018-08-01'); // true
Carbon::parse('2018-07-25')->between('2018-07-25', '2018-08-01', false); // false
| Prototype 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 |
DateTimeInterface|string $date1, DateTimeInterface|string $date2
boolDetermines if the instance is between two others, bounds included.
Examples:
Carbon::parse('2018-07-25')->betweenIncluded('2018-07-14', '2018-08-01'); // true
Carbon::parse('2018-07-25')->betweenIncluded('2018-08-01', '2018-08-20'); // false
Carbon::parse('2018-07-25')->betweenIncluded('2018-07-25', '2018-08-01'); // true
| Prototype changed | 3.0.0 | DateTimeInterface|string $date1, DateTimeInterface|string $date2 |
| Method added | 2.31.0 | $date1, $date2 |
DateTimeInterface|string $date1, DateTimeInterface|string $date2
boolDetermines if the instance is between two others, bounds excluded.
Examples:
Carbon::parse('2018-07-25')->betweenExcluded('2018-07-14', '2018-08-01'); // true
Carbon::parse('2018-07-25')->betweenExcluded('2018-08-01', '2018-08-20'); // false
Carbon::parse('2018-07-25')->betweenExcluded('2018-07-25', '2018-08-01'); // false
| Prototype changed | 3.0.0 | DateTimeInterface|string $date1, DateTimeInterface|string $date2 |
| Method added | 2.22.0 | $date1, $date2 |
DateTimeInterface|string $date1, DateTimeInterface|string $date2, bool $equal = true
boolDetermines if the instance is between two others
Examples:
Carbon::parse('2018-07-25')->isBetween('2018-07-14', '2018-08-01'); // true
Carbon::parse('2018-07-25')->isBetween('2018-08-01', '2018-08-20'); // false
Carbon::parse('2018-07-25')->isBetween('2018-07-25', '2018-08-01'); // true
Carbon::parse('2018-07-25')->isBetween('2018-07-25', '2018-08-01', false); // false
| Prototype changed | 3.0.0 | DateTimeInterface|string $date1, DateTimeInterface|string $date2, bool $equal = true |
| Method added | 1.39.0 | $date1, $date2, $equal = true |
boolDetermines if the instance is a weekday.
Examples:
Carbon::parse('2019-07-14')->isWeekday(); // false
Carbon::parse('2019-07-15')->isWeekday(); // true
| Method added | 1.0.0 | no arguments |
boolDetermines if the instance is a weekend day.
Examples:
Carbon::parse('2019-07-14')->isWeekend(); // true
Carbon::parse('2019-07-15')->isWeekend(); // false
| Method added | 1.0.0 | no arguments |
boolDetermines if the instance is yesterday.
Examples:
Carbon::yesterday()->isYesterday(); // true
Carbon::tomorrow()->isYesterday(); // false
| Method added | 1.0.0 | no arguments |
boolDetermines if the instance is today.
Examples:
Carbon::today()->isToday(); // true
Carbon::tomorrow()->isToday(); // false
| Method added | 1.0.0 | no arguments |
boolDetermines if the instance is tomorrow.
Examples:
Carbon::tomorrow()->isTomorrow(); // true
Carbon::yesterday()->isTomorrow(); // false
| Method added | 1.0.0 | no arguments |
boolDetermines if the instance is in the future, ie. greater (after) than now.
Examples:
Carbon::now()->addHours(5)->isFuture(); // true
Carbon::now()->subHours(5)->isFuture(); // false
| Method added | 1.0.0 | no arguments |
boolDetermines if the instance is in the past, ie. less (before) than now.
Examples:
Carbon::now()->subHours(5)->isPast(); // true
Carbon::now()->addHours(5)->isPast(); // false
| Method added | 1.0.0 | no arguments |
boolDetermines if the instance is now or in the future, ie. greater (after) than or equal to now.
Examples:
Carbon::now()->isNowOrFuture(); // true
Carbon::now()->addHours(5)->isNowOrFuture(); // true
Carbon::now()->subHours(5)->isNowOrFuture(); // false
| Method added | 3.9.0 | no arguments |
boolDetermines if the instance is now or in the past, ie. less (before) than or equal to now.
Examples:
Carbon::now()->isNowOrPast(); // true
Carbon::now()->subHours(5)->isNowOrPast(); // true
Carbon::now()->addHours(5)->isNowOrPast(); // false
| Method added | 3.9.0 | no arguments |
boolDetermines if the instance is a leap year.
Examples:
Carbon::parse('2020-01-01')->isLeapYear(); // true
Carbon::parse('2019-01-01')->isLeapYear(); // false
| Method added | 1.0.0 | no arguments |
boolDetermines if the instance is a long year (using calendar year).
⚠️ This method completely ignores month and day to use the numeric year number,
it's not correct if the exact date matters. For instance as `2019-12-30` is already
in the first week of the 2020 year, if you want to know from this date if ISO week
year 2020 is a long year, use `isLongIsoYear` instead.
Examples:
Carbon::create(2015)->isLongYear(); // true
Carbon::create(2016)->isLongYear(); // false
| Method added | 1.22.0 | no arguments |
boolDetermines if the instance is a long year (using ISO 8601 year).
Examples:
Carbon::parse('2015-01-01')->isLongIsoYear(); // true
Carbon::parse('2016-01-01')->isLongIsoYear(); // true
Carbon::parse('2016-01-03')->isLongIsoYear(); // false
Carbon::parse('2019-12-29')->isLongIsoYear(); // false
Carbon::parse('2019-12-30')->isLongIsoYear(); // true
| Method added | 2.65.0 | no arguments |
string $format, DateTimeInterface|string $date
boolCompares the formatted values of the two dates.
Examples:
Carbon::parse('2019-06-13')->isSameAs('Y-d', Carbon::parse('2019-12-13')); // true
Carbon::parse('2019-06-13')->isSameAs('Y-d', Carbon::parse('2019-06-14')); // false
| Prototype 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 |
string $unit, DateTimeInterface|string $date
boolDetermines if the instance is in the current unit given.
Examples:
Carbon::parse('2019-01-13')->isSameUnit('year', Carbon::parse('2019-12-25')); // true
Carbon::parse('2018-12-13')->isSameUnit('year', Carbon::parse('2019-12-25')); // false
| Prototype changed | 3.0.0 | string $unit, DateTimeInterface|string $date |
| Method added | 2.0.0 | $unit, $date = null |
string $unit
boolDetermines if the instance is in the current unit given.
Examples:
Carbon::now()->isCurrentUnit('hour'); // true
Carbon::now()->subHours(2)->isCurrentUnit('hour'); // false
| Prototype changed | 3.0.0 | string $unit |
| Method added | 2.0.0 | $unit |
DateTimeInterface|string $date, bool $ofSameYear = true
boolChecks if the passed in date is in the same quarter as the instance quarter (and year if needed).
Examples:
Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2019-03-01')); // true
Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2019-04-01')); // false
Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2018-03-01')); // false
Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2018-03-01'), false); // true
| Prototype 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 |
DateTimeInterface|string $date, bool $ofSameYear = true
boolChecks if the passed in date is in the same month as the instance´s month.
Examples:
Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2019-01-01')); // true
Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2019-02-01')); // false
Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2018-01-01')); // false
Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2018-01-01'), false); // true
| Prototype 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 |
$dayOfWeek
boolChecks if this day is a specific day of the week.
Examples:
Carbon::parse('2019-07-17')->isDayOfWeek(Carbon::WEDNESDAY); // true
Carbon::parse('2019-07-17')->isDayOfWeek(Carbon::FRIDAY); // false
Carbon::parse('2019-07-17')->isDayOfWeek('Wednesday'); // true
Carbon::parse('2019-07-17')->isDayOfWeek('Friday'); // false
| Method added | 1.24.0 | $dayOfWeek |
DateTimeInterface|string|null $date = null
boolCheck if its the birthday. Compares the date/month values of the two dates.
Examples:
Carbon::now()->subYears(5)->isBirthday(); // true
Carbon::now()->subYears(5)->subDay()->isBirthday(); // false
Carbon::parse('2019-06-05')->isBirthday(Carbon::parse('2001-06-05')); // true
Carbon::parse('2019-06-05')->isBirthday(Carbon::parse('2001-06-06')); // false
| Prototype 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 |
boolCheck if today is the last day of the Month
Examples:
Carbon::parse('2019-02-28')->isLastOfMonth(); // true
Carbon::parse('2019-03-28')->isLastOfMonth(); // false
Carbon::parse('2019-03-30')->isLastOfMonth(); // false
Carbon::parse('2019-03-31')->isLastOfMonth(); // true
Carbon::parse('2019-04-30')->isLastOfMonth(); // true
| Method added | 1.24.0 | no arguments |
Carbon\Unit $unit, Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, mixed $params
boolCheck if the instance is start of a given unit (tolerating a given interval).
Examples:
// Check if a date-time is the first 15 minutes of the hour it's in
Carbon::parse('2019-02-28 20:13:00')->isStartOfUnit(Unit::Hour, '15 minutes'); // true
| Method added | 3.8.0 | Carbon\Unit $unit, Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, mixed $params |
Carbon\Unit $unit, Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, mixed $params
boolCheck if the instance is end of a given unit (tolerating a given interval).
Examples:
// Check if a date-time is the last 15 minutes of the hour it's in
Carbon::parse('2019-02-28 20:13:00')->isEndOfUnit(Unit::Hour, '15 minutes'); // false
| Method added | 3.8.0 | Carbon\Unit $unit, Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, mixed $params |
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|bool $checkMicroseconds = false, Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolCheck if the instance is start of day / midnight.
Examples:
Carbon::parse('2019-02-28 00:00:00')->isStartOfDay(); // true
Carbon::parse('2019-02-28 00:00:00.999999')->isStartOfDay(); // true
Carbon::parse('2019-02-28 00:00:01')->isStartOfDay(); // false
Carbon::parse('2019-02-28 00:00:00.000000')->isStartOfDay(true); // true
Carbon::parse('2019-02-28 00:00:00.000012')->isStartOfDay(true); // false
| Prototype 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|bool $checkMicroseconds = false, Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolCheck if the instance is end of day.
Examples:
Carbon::parse('2019-02-28 23:59:59.999999')->isEndOfDay(); // true
Carbon::parse('2019-02-28 23:59:59.123456')->isEndOfDay(); // true
Carbon::parse('2019-02-28 23:59:59')->isEndOfDay(); // true
Carbon::parse('2019-02-28 23:59:58.999999')->isEndOfDay(); // false
Carbon::parse('2019-02-28 23:59:59.999999')->isEndOfDay(true); // true
Carbon::parse('2019-02-28 23:59:59.123456')->isEndOfDay(true); // false
Carbon::parse('2019-02-28 23:59:59')->isEndOfDay(true); // false
| Prototype 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, Carbon\WeekDay|int|null $weekStartsAt = null
boolDetermines if the instance is start of week (first day by default but interval can be customized).
Examples:
Carbon::parse('2024-08-31')->startOfWeek()->isStartOfWeek(); // true
Carbon::parse('2024-08-31')->isStartOfWeek(); // false
| Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, Carbon\WeekDay|int|null $weekStartsAt = null |
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, Carbon\WeekDay|int|null $weekEndsAt = null
boolDetermines if the instance is end of week (last day by default but interval can be customized).
Examples:
Carbon::parse('2024-08-31')->endOfWeek()->isEndOfWeek(); // true
Carbon::parse('2024-08-31')->isEndOfWeek(); // false
| Method added | 3.8.0 | Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null, Carbon\WeekDay|int|null $weekEndsAt = null |
Carbon\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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\Unit|DateInterval|Closure|Carbon\CarbonConverterInterface|string|null $interval = null
boolDetermines 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 |
boolCheck if the instance is start of day / midnight.
Examples:
Carbon::parse('2019-02-28 00:00:00')->isMidnight(); // true
Carbon::parse('2019-02-28 00:00:00.999999')->isMidnight(); // true
Carbon::parse('2019-02-28 00:00:01')->isMidnight(); // false
| Method added | 1.28.0 | no arguments |
boolCheck if the instance is midday.
Examples:
Carbon::parse('2019-02-28 11:59:59.999999')->isMidday(); // false
Carbon::parse('2019-02-28 12:00:00')->isMidday(); // true
Carbon::parse('2019-02-28 12:00:00.999999')->isMidday(); // true
Carbon::parse('2019-02-28 12:00:01')->isMidday(); // false
| Method added | 1.28.0 | no arguments |
string $date, string $format
boolChecks if the (date)time string is in a given format.
Examples:
Carbon::hasFormat('11:12:45', 'h:i:s'); // true
Carbon::hasFormat('13:12:45', 'h:i:s'); // false
| Prototype changed | 3.0.0 | string $date, string $format |
| Method added | 1.24.0 | $date, $format |
?string $date, string $format
boolChecks if the (date)time string is in a given format.
Examples:
Carbon::hasFormatWithModifiers('31/08/2015', 'd#m#Y'); // true
Carbon::hasFormatWithModifiers('31/08/2015', 'm#d#Y'); // false
| Prototype changed | 3.0.0 | ?string $date, string $format |
| Prototype changed | 2.41.2 | $date, $format |
| Method added | 2.41.0 | string $date, string $format |
?string $date, string $format
boolChecks if the (date)time string is in a given format and valid to create a new instance.
Examples:
Carbon::canBeCreatedFromFormat('11:12:45', 'h:i:s'); // true
Carbon::canBeCreatedFromFormat('13:12:45', 'h:i:s'); // false
| Prototype changed | 3.0.0 | ?string $date, string $format |
| Method added | 2.39.1 | $date, $format |
Carbon\WeekDay|Carbon\Month|string $tester
boolReturns true if the current date matches the given string.
Examples:
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2018')); // false
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019-06')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('06-02')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019-06-02')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('Sunday')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('June')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23:45')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23:00')); // false
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12h')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 15:23:45')->is('3pm')); // true
\Carbon\Doc\Generate\var_dump(Carbon::parse('2019-06-02 15:23:45')->is('3am')); // false
| Prototype changed | 3.6.0 | Carbon\WeekDay|Carbon\Month|string $tester |
| Method added | 2.20.0 | string $tester |
boolReturns true if the date was created using CarbonImmutable::startOfTime()
| Method added | 2.48.0 | no arguments |
boolReturns true if the date was created using CarbonImmutable::endOfTime()
| Method added | 2.48.0 | no arguments |
string $format
stringSee php.net/manual/en/datetime.format.php
| Prototype changed | 3.0.0 | string $format |
| Method added | 2.16.0 | $format |
stringFormat the instance as a string using the set format
Examples:
echo Carbon::now(); // Carbon instances can be cast to string
| Method added | 1.0.0 | no arguments |
stringFormat the instance as date
Examples:
echo Carbon::now()->toDateString();
| Method added | 1.0.0 | no arguments |
stringFormat the instance as a readable date
Examples:
echo Carbon::now()->toFormattedDateString();
| Method added | 1.0.0 | no arguments |
stringFormat the instance with the day, and a readable date
Examples:
echo Carbon::now()->toFormattedDayDateString();
| Method added | 2.62.0 | no arguments |
string $unitPrecision = 'second'
stringFormat 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 |
string $unitPrecision = 'second'
stringFormat 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 |
string $unitPrecision
stringReturn a format from H:i to H:i:s.u according to given unit precision.
| Prototype changed | 3.0.0 | string $unitPrecision |
| Method added | 2.26.0 | $unitPrecision |
string $unitPrecision = 'second'
stringFormat the instance as date and time T-separated with no timezone
Examples:
echo Carbon::now()->toDateTimeLocalString();
echo "\n";
echo Carbon::now()->toDateTimeLocalString('minute'); // You can specify precision among: minute, second, millisecond and microsecond
| Prototype changed | 3.0.0 | string $unitPrecision = 'second' |
| Prototype changed | 2.26.0 | $unitPrecision = 'second' |
| Method added | 1.39.0 | no arguments |
stringFormat the instance with day, date and time
Examples:
echo Carbon::now()->toDayDateTimeString();
| Method added | 1.0.0 | no arguments |
stringFormat the instance as ATOM
Examples:
echo Carbon::now()->toAtomString();
| Method added | 1.13.0 | no arguments |
stringFormat the instance as COOKIE
Examples:
echo Carbon::now()->toCookieString();
| Method added | 1.13.0 | no arguments |
stringFormat the instance as ISO8601
Examples:
echo Carbon::now()->toIso8601String();
| Method added | 1.13.0 | no arguments |
stringFormat the instance as RFC822
Examples:
echo Carbon::now()->toRfc822String();
| Method added | 1.13.0 | no arguments |
string $unitPrecision = 'second'
stringConvert 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 |
stringFormat the instance as RFC850
Examples:
echo Carbon::now()->toRfc850String();
| Method added | 1.13.0 | no arguments |
stringFormat the instance as RFC1036
Examples:
echo Carbon::now()->toRfc1036String();
| Method added | 1.13.0 | no arguments |
stringFormat the instance as RFC1123
Examples:
echo Carbon::now()->toRfc1123String();
| Method added | 1.13.0 | no arguments |
stringFormat the instance as RFC2822
Examples:
echo Carbon::now()->toRfc2822String();
| Method added | 1.13.0 | no arguments |
bool $extended = false
stringFormat 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 |
stringFormat the instance as RSS
Examples:
echo Carbon::now()->toRssString();
| Method added | 1.13.0 | no arguments |
stringFormat the instance as W3C
Examples:
echo Carbon::now()->toW3cString();
| Method added | 1.13.0 | no arguments |
stringFormat the instance as RFC7231
Examples:
echo Carbon::now()->toRfc7231String();
| Method added | 1.24.0 | no arguments |
arrayGet default array representation.
Examples:
\Carbon\Doc\Generate\var_dump(Carbon::now()->toArray());
| Method added | 1.24.0 | no arguments |
objectGet default object representation.
Examples:
\Carbon\Doc\Generate\var_dump(Carbon::now()->toObject());
| Method added | 1.39.0 | no arguments |
stringReturns english human-readable complete date string.
Examples:
echo Carbon::now()->toString();
| Method added | 1.39.0 | no arguments |
bool $keepOffset = false
stringReturn 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 |
stringReturn 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 |
DateTimeReturn native DateTime PHP object matching the current instance.
Examples:
\Carbon\Doc\Generate\var_dump(Carbon::now()->toDateTime());
| Method added | 1.39.0 | no arguments |
DateTimeImmutableReturn native toDateTimeImmutable PHP object matching the current instance.
Examples:
\Carbon\Doc\Generate\var_dump(Carbon::now()->toDateTimeImmutable());
| Method added | 2.23.0 | no arguments |
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 |
$end = null, $interval = null, $unit = null
CarbonPeriodCreate 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 |
$end = null, $interval = null, $unit = null
CarbonPeriodCreate 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 |
Reset the format used to the default when type juggling a Carbon instance to a string
| Method added | 1.5.0 | no arguments |
Closure|string|null $format
| Prototype changed | 3.0.0 | Closure|string|null $format |
| Method added | 1.5.0 | $format |
Update constructedObjectId on cloned.
| Method added | 2.29.0 | no arguments |
DateTimeInterface $date
CarbonCreate 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 |
DateTimeInterface|Carbon\WeekDay|Carbon\Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = null
CarbonCreate 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 |
DateTimeInterface|Carbon\WeekDay|Carbon\Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = null
CarbonCreate 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 |
string $time, ?string $locale = null, DateTimeZone|string|int|null $timezone = null
CarbonCreate 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 |
DateTimeZone|string|int|null $timezone = null
CarbonGet 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 |
DateTimeZone|string|int|null $timezone = null
CarbonCreate a Carbon instance for today.
| Prototype changed | 3.0.0 | DateTimeZone|string|int|null $timezone = null |
| Method added | 1.1.0 | $tz = null |
DateTimeZone|string|int|null $timezone = null
CarbonCreate a Carbon instance for tomorrow.
| Prototype changed | 3.0.0 | DateTimeZone|string|int|null $timezone = null |
| Method added | 1.1.0 | $tz = null |
DateTimeZone|string|int|null $timezone = null
CarbonCreate a Carbon instance for yesterday.
| Prototype changed | 3.0.0 | DateTimeZone|string|int|null $timezone = null |
| Method added | 1.1.0 | $tz = null |
$year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $timezone = null
CarbonCreate 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 |
$year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null
CarbonCreate 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 |
?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $timezone = null
CarbonCreate 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 |
$year = null, $month = null, $day = null, $timezone = null
CarbonCreate 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 |
$year = null, $month = null, $day = null, $timezone = null
CarbonCreate 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 |
$hour = 0, $minute = 0, $second = 0, $timezone = null
CarbonCreate 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 |
string $time, DateTimeZone|string|int|null $timezone = null
CarbonCreate 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 |
string $format, string $time, $timezone = null
CarbonCreate a Carbon instance from a specific format.
| Prototype changed | 3.0.0 | string $format, string $time, $timezone = null |
| Method added | 2.16.0 | $format, $time, $tz = null |
string $format, string $time, $timezone = null, ?string $locale = 'en', ?Symfony\Contracts\Translation\TranslatorInterface $translator = null
CarbonCreate a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).
| Prototype changed | 3.0.0 | string $format, string $time, $timezone = null, ?string $locale = 'en', ?Symfony\Contracts\Translation\TranslatorInterface $translator = null |
| Method added | 2.16.0 | $format, $time, $tz = null, $locale = 'en', $translator = null |
string $format, string $locale, string $time, $timezone = null
CarbonCreate a Carbon instance from a specific format and a string in a given language.
| Prototype changed | 3.0.0 | string $format, string $locale, string $time, $timezone = null |
| Method added | 2.16.0 | $format, $locale, $time, $tz = null |
string $format, string $locale, string $time, $timezone = null
CarbonCreate a Carbon instance from a specific ISO format and a string in a given language.
| Prototype changed | 3.0.0 | string $format, string $locale, string $time, $timezone = null |
| Method added | 2.16.0 | $format, $locale, $time, $tz = null |
$var, DateTimeZone|string|null $timezone = null
CarbonMake 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 |
WrapperClock| Method added | 3.0.0 | no arguments |
$date = null, bool $absolute = false
DateIntervalGet 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 |
$date = null, bool $absolute = false, array $skip = []
CarbonIntervalGet 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\Unit|string $unit, $date = null, bool $absolute = false, bool $utc = false
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 |
$date = null, bool $absolute = false, bool $utc = false
floatGet 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 |
$date = null, bool $absolute = false, bool $utc = false
floatGet 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 |
$date = null, bool $absolute = false, bool $utc = false
floatGet 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 |
$date = null, bool $absolute = false, bool $utc = false
floatGet 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 |
$date = null, bool $absolute = false, bool $utc = false
floatGet 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 |
Closure $callback, $date = null, bool $absolute = false
intGet 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 |
Closure $callback, $date = null, bool $absolute = false
intGet 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\CarbonInterval $ci, Closure $callback, $date = null, bool $absolute = false
intGet 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 |
$date = null, bool $absolute = false
intGet 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 |
$date = null, bool $absolute = false
intGet 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 |
$date = null, bool $absolute = false
floatGet 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 |
$date = null, bool $absolute = false
floatGet 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 |
$date = null, bool $absolute = false
floatGet 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 |
$date = null, bool $absolute = false
floatGet the difference in microseconds.
| Prototype changed | 3.0.0 | $date = null, bool $absolute = false |
| Method added | 1.39.0 | $date = null, $absolute = true |
$date = null, bool $absolute = false
floatGet the difference in milliseconds.
| Prototype changed | 3.0.0 | $date = null, bool $absolute = false |
| Method added | 1.39.0 | $date = null, $absolute = true |
floatThe number of seconds since midnight.
| Method added | 1.14.0 | no arguments |
floatThe number of seconds until 23:59:59.
| Method added | 1.14.0 | no arguments |
$other = null, $syntax = null, $short = false, $parts = 1, $options = null
stringGet 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 |
$other = null, $syntax = null, $short = false, $parts = 1, $options = null
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 |
$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 |
$other = null, $syntax = null, $short = false, $parts = 1, $options = null
stringGet 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 |
$other = null, $syntax = null, $short = false, $parts = 1, $options = null
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 |
$syntax = null, $short = false, $parts = 1, $options = null
stringGet 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 |
$syntax = null, $short = false, $parts = 1, $options = null
stringGet 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 |
$syntax = null, $short = false, $parts = 1, $options = null
stringGet 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 |
$other = null, $timezone = null
stringGet 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 |
$referenceTime = null, array $formats = []
stringReturns 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 = [] |
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 |
Remove all macros and generic macros.
| Method added | 1.39.0 | no arguments |
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 |
string $name
boolChecks if macro is registered globally.
| Prototype changed | 3.0.0 | string $name |
| Method added | 1.26.0 | $name |
string $name
callableGet the raw callable macro registered globally for a given name.
| Prototype changed | 3.0.0 | string $name |
| Method added | 2.29.0 | $name |
string $name
boolChecks if macro is registered globally or locally.
| Prototype changed | 3.0.0 | string $name |
| Method added | 2.29.0 | $name |
string $name
callableGet 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 |
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 |
intget midday/noon hour
| Method added | 1.24.0 | no arguments |
$hour
| Method added | 1.24.0 | $hour |
CarbonModify to midday, default to self::$midDayAt
| Method added | 1.24.0 | no arguments |
$modifier = null
CarbonModify 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 |
CarbonGo forward to the next weekday.
| Method added | 1.22.0 | no arguments |
CarbonGo backward to the previous weekday.
| Method added | 1.22.0 | no arguments |
CarbonGo forward to the next weekend day.
| Method added | 1.22.0 | no arguments |
CarbonGo backward to the previous weekend day.
| Method added | 1.22.0 | no arguments |
$modifier = null
CarbonModify 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 |
$dayOfWeek = null
CarbonModify 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 |
$dayOfWeek = null
CarbonModify 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 |
$nth, $dayOfWeek
mixedModify 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 |
$dayOfWeek = null
CarbonModify 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 |
$dayOfWeek = null
CarbonModify 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 |
$nth, $dayOfWeek
mixedModify 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 |
$dayOfWeek = null
CarbonModify 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 |
$dayOfWeek = null
CarbonModify 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 |
$nth, $dayOfWeek
mixedModify 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 |
$date = null
CarbonModify 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 |
$date1, $date2
CarbonGet 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 |
$date1, $date2
CarbonGet 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 |
$date = null
CarbonGet 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 |
$date = null
CarbonGet 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 |
$date = null
CarbonGet 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 |
$date = null
CarbonGet 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 |
$modifier
CarbonSimilar to native modify() method of DateTime but can handle more grammars.
Examples:
echo Carbon::now()->change('next 2pm');
| Method added | 2.20.0 | $modifier |
boolReturns true if the current class/instance is immutable.
| Method added | 2.0.0 | no arguments |
CarbonReturn a mutable copy of the instance.
| Method added | 2.0.0 | no arguments |
CarbonImmutableReturn a immutable copy of the instance.
| Method added | 2.0.0 | no arguments |
string $className
mixedCast the current instance into the given class.
| Prototype changed | 2.8.0 | string $className |
| Method added | 1.39.0 | $className |
array $settings
CarbonSet 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 |
arrayReturns current local settings.
| Method added | 2.3.0 | no arguments |
arrayShow truthy properties on \Carbon\Doc\Generate\var_dump().
| Method added | 1.39.0 | no arguments |
bool $strictModeEnabled = true
| Prototype changed | 3.0.0 | bool $strictModeEnabled = true |
| Method added | 2.0.0 | $strictModeEnabled = true |
boolReturns 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 |
bool $monthsOverflow = true
| Prototype changed | 3.0.0 | bool $monthsOverflow = true |
| Method added | 1.22.0 | $monthsOverflow = true |
| Method added | 1.22.0 | no arguments |
boolGet the month overflow global behavior (can be overridden in specific instances).
| Method added | 1.22.0 | no arguments |
bool $yearsOverflow = true
| Prototype changed | 3.0.0 | bool $yearsOverflow = true |
| Method added | 1.24.0 | $yearsOverflow = true |
| Method added | 1.24.0 | no arguments |
boolGet the month overflow global behavior (can be overridden in specific instances).
| Method added | 1.24.0 | no arguments |
boolReturn true if the current instance has its own translator.
| Method added | 2.29.0 | no arguments |
Symfony\Contracts\Translation\TranslatorInterfaceGet the translator of the current instance or the default if none set.
| Method added | 2.0.0 | no arguments |
Symfony\Contracts\Translation\TranslatorInterface $translator
CarbonSet 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 |
$translator, string $key, ?string $locale = null, ?string $default = null
string|Closure|nullReturns raw translation message for a given key.
| Method added | 2.8.0 | $translator, string $key, ?string $locale = null, ?string $default = null |
string $key, ?string $locale = null, ?string $default = null, $translator = null
stringReturns 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 |
Symfony\Contracts\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null
stringTranslate 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 |
string $key, array $parameters = [], string|int|float|null $number = null, ?Symfony\Contracts\Translation\TranslatorInterface $translator = null, bool $altNumbers = false
stringTranslate 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 |
int $number
stringReturns the alternative number for a given integer if available in the current locale.
| Method added | 2.23.0 | int $number |
string $timeString, ?string $from = null, ?string $to = null, int $mode = 31
stringTranslate 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 |
string $timeString, ?string $to = null
stringTranslate a time string from the current locale (`$date->locale()`) to another one.
| Prototype changed | 3.0.0 | string $timeString, ?string $to = null |
| Method added | 2.16.0 | $timeString, $to = null |
?string $locale = null, string $fallbackLocales
Carbon|stringGet/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 |
stringGet the current translator locale.
| Method added | 1.18.0 | no arguments |
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 |
string $locale
Set the fallback locale.
| Prototype changed | 3.0.0 | string $locale |
| Method added | 2.16.0 | $locale |
stringGet the fallback locale.
| Method added | 2.16.0 | no arguments |
string $locale, callable $func
mixedSet 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 |
string $locale
boolReturns 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 |
string $locale
boolReturns 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 |
string $locale
boolReturns 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 |
string $locale
boolReturns 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 |
$locale
boolReturns 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 |
arrayReturns 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 |
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 |
int $humanDiffOptions
| Prototype changed | 3.0.0 | int $humanDiffOptions |
| Method added | 1.26.0 | $humanDiffOptions |
int $humanDiffOption
| Prototype changed | 3.0.0 | int $humanDiffOption |
| Method added | 1.26.0 | $humanDiffOption |
int $humanDiffOption
| Prototype changed | 3.0.0 | int $humanDiffOption |
| Method added | 1.26.0 | $humanDiffOption |
intReturn default humanDiff() options (merged flags as integer).
| Method added | 1.26.0 | no arguments |
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 |
Symfony\Contracts\Translation\TranslatorInterfaceInitialize the default translator instance if necessary.
| Method added | 1.18.0 | no arguments |
string $unit, DateInterval|string|int|float $precision = 1, callable|string $function = 'round'
CarbonRound 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' |
string $unit, DateInterval|string|int|float $precision = 1
CarbonTruncate 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 |
string $unit, DateInterval|string|int|float $precision = 1
CarbonCeil 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 |
DateInterval|string|int|float $precision = 1, callable|string $function = 'round'
CarbonRound 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' |
DateInterval|string|int|float $precision = 1
CarbonRound 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 |
DateInterval|string|int|float $precision = 1
CarbonCeil 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\WeekDay|int|null $weekStartsAt = null
CarbonRound the current instance week.
| Prototype changed | 3.0.0 | Carbon\WeekDay|int|null $weekStartsAt = null |
| Method added | 2.0.0 | $weekStartsAt = null |
Carbon\WeekDay|int|null $weekStartsAt = null
CarbonTruncate the current instance week.
| Prototype changed | 3.0.0 | Carbon\WeekDay|int|null $weekStartsAt = null |
| Method added | 2.0.0 | $weekStartsAt = null |
Carbon\WeekDay|int|null $weekStartsAt = null
CarbonCeil the current instance week.
| Prototype changed | 3.0.0 | Carbon\WeekDay|int|null $weekStartsAt = null |
| Method added | 2.0.0 | $weekStartsAt = null |
stringReturn a serialized string of the instance.
| Method added | 1.22.0 | no arguments |
$value, array $options = []
CarbonCreate an instance from a serialized string.
If $value is not from a trusted source, consider using the allowed_classes option to limit
the types of objects that can be built, for instance:
Examples:
$object = Carbon::fromSerialized($value, ['allowed_classes' => [Carbon::class, CarbonImmutable::class]]);
| Prototype changed | 3.10.0 | $value, array $options = [] |
| Method added | 1.22.0 | $value |
arrayReturns the list of properties to dump on serialize() called on.
Only used by PHP < 7.4.
| Method added | 2.0.0 | no arguments |
mixedPrepare the object for JSON serialization.
| Method added | 1.26.0 | no arguments |
callable|string|null $format
| Prototype changed | 3.0.0 | callable|string|null $format |
| Method added | 1.26.0 | $callback |
CarbonCleanup 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 |
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 |
$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 |
mixed $testNow, callable $callback
mixedTemporarily 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 |
Closure|CarbonInterface|nullGet the Carbon instance (real or mock) to be returned when a "now" instance is created.
| Method added | 1.3.0 | no arguments |
boolDetermine 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 |
string|int|float $timestamp, DateTimeZone|string|int|null $timezone = null
CarbonCreate 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 |
string|int|float $timestamp
CarbonCreate 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 |
$timestamp
CarbonCreate 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 |
string|int|float $timestamp, DateTimeZone|string|int|null $timezone = null
CarbonCreate 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 |
string|int|float $timestamp
CarbonSet 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 |
$precision = 6
floatReturns 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 |
floatReturns the milliseconds timestamps used amongst other by Date javascript objects.
| Method added | 2.0.0 | no arguments |
intReturns the timestamp with millisecond precision.
| Method added | 2.51.0 | no arguments |
int@alias getTimestamp
Returns the UNIX timestamp for the current date.
| Method added | 2.0.0 | no arguments |
string $unit, $value = 1
Carbon| Prototype changed | 3.0.0 | string $unit, $value = 1 |
| Method added | 2.0.0 | $unit, $value = 1 |
string $unit, $value = 1
CarbonAdd 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 |
$unit, $value = 1
Carbon| Method added | 2.0.0 | $unit, $value = 1 |
$unit, $value = 1
CarbonSubtract 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 |
$unit
boolReturns true if a property can be changed via setter.
| Method added | 2.0.0 | $unit |
DateInterval $interval
CarbonCall native PHP DateTime/DateTimeImmutable add() method.
| Method added | 2.36.0 | DateInterval $interval |
Carbon\Unit|string $unit, $value = 1, ?bool $overflow = null
CarbonAdd 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\Unit|string $unit, $value = 1, ?bool $overflow = null
CarbonSubtract 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 |
DateInterval $interval
CarbonCall native PHP DateTime/DateTimeImmutable sub() method.
| Method added | 2.36.0 | DateInterval $interval |
$unit, $value = 1, ?bool $overflow = null
CarbonSubtract 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 |
$year = null, $dayOfWeek = null, $dayOfYear = null
int|CarbonSet/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 |
$year = null, $dayOfWeek = null, $dayOfYear = null
int|CarbonSet/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 |
$dayOfWeek = null, $dayOfYear = null
intGet 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 |
$dayOfWeek = null, $dayOfYear = null
intGet 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 |
$week = null, $dayOfWeek = null, $dayOfYear = null
int|CarbonGet/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 |
$week = null, $dayOfWeek = null, $dayOfYear = null
int|CarbonGet/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 |
stringReturns day English name in lower case.
Spatie\OpeningHours\OpeningHoursReturns an OpeningHours instance (the one given if already an instance of OpeningHours, or else create a new one from array definition given).
$this|nullSet the opening hours for the class/instance.
$this|nullReset the opening hours for the class/instance.
Spatie\OpeningHours\OpeningHoursGet the opening hours of the class/instance.
mixedCall a method on the OpeningHours of the current instance.
Carbon|CarbonImmutable|CarbonInterface|boolGet 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|CarbonImmutable|CarbonInterfaceLoop on the current instance (or now if called statically) with a given method until it's not a holiday.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceAdd a given number of business days to the current date.
Carbon|CarbonImmutable|CarbonInterfaceAdd a given number of business days to the current date.
Carbon|CarbonImmutable|CarbonInterfaceAdd a given number of business days to the current date.
Carbon|CarbonImmutable|CarbonInterfaceAdd a given number of business days to the current date.
Carbon|CarbonImmutable|CarbonInterfaceAdd a given number of business days to the current date.
Carbon|CarbonImmutable|CarbonInterfaceAdd a given number of business days to the current date.
intReturn a number of days with open/closed business time between the current date and another given date.
intGet the number of business days in the current month.
arrayGet list of date objects for each business day in the current month.
$this|nullChecks the date to see if it is a business day (neither a weekend day nor a holiday).
boolChecks the date to see if it is a business day (extra workday or neither a weekend day nor a holiday).
CarbonInterface|Carbon|CarbonImmutableSets the date to the next business day (neither a weekend day nor a holiday).
CarbonInterface|Carbon|CarbonImmutableSets the date to the current or next business day (neither a weekend day nor a holiday).
CarbonInterface|Carbon|CarbonImmutableSets the date to the next business day (neither a weekend day nor a holiday).
CarbonInterface|Carbon|CarbonImmutableSets the date to the current or next business day (neither a weekend day nor a holiday).
$this|nullSet the selected zone for observed holidays. So next observe methods will be saved and considered in this given custom zone.
string|nullGet the selected zone for observed holidays.
$this|nullSet a holiday as observed/unobserved in the selected zone.
$this|nullSet a holiday as observed/unobserved in the selected zone (can take array of holidays).
$this|nullSet a holiday as observed/unobserved in the selected zone (can take array of holidays).
$this|nullSet a holiday as observed/unobserved in the selected zone (can take array of holidays).
$this|nullSet a holiday as observed/unobserved in the selected zone (can take array of holidays).
$this|nullSet a holiday as observed/unobserved in the selected zone (can take array of holidays).
$this|nullSet a holiday as observed/unobserved in the selected zone (can take array of holidays).
$this|nullSet a holiday as observed/unobserved in the selected zone (can take array of holidays).
boolCheck if a given holiday ID is observed in the selected zone.
boolChecks the date to see if it is a holiday observed in the selected zone.
$this|nullSet the strategy to get the holiday ID from a date object.
$this|nullSet the strategy to get the extra workday ID from a date object.
string|falseGet the identifier of the current holiday or false if it's not a holiday.
string|falseGet the identifier of the current holiday or false if it's not a holiday.
boolChecks the date to see if it is a holiday.
string|falseGet the identifier of the current special workday or false if it's not a special workday.
boolChecks the date to see if it is a holiday.
arrayGet the holidays in the given language.
string|falseGet 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.
arrayGet the holidays dates for a given year (current year if no parameter given).
callableGet a next() callback to call to iterate over holidays of a year.
stringReturn a standardized region name.
arrayGet the current holidays region.
Set the holidays region (see src/Cmixin/Holidays for examples).
null|stringGet the current holidays region.
arrayGet the holidays for the current region selected.
arrayGet the holidays for the current region selected.
arrayGet the holidays for the current region selected.
Carbon|CarbonImmutable|CarbonInterface|nullPush a day into a given list list of a region.
Carbon|CarbonImmutable|CarbonInterface|nullPush a holiday to the holidays list of a region.
Carbon|CarbonImmutable|CarbonInterface|nullPush a workday to the workdays list of a region.
Carbon|CarbonImmutable|CarbonInterface|nullSet/change the name of holiday by ID for a given language (or a list of languages).
Carbon|CarbonImmutable|CarbonInterface|nullAdd a holiday to the holidays list of a region and optionally init its ID, name and observed state.
Carbon|CarbonImmutable|CarbonInterface|nullAdd a workday to the workdays list of a region and optionally init its ID and name.
arrayUnpack a holiday array definition.
arrayCheck a holiday definition and unpack it if it's an array.
Add a holiday to the holidays list of a region and optionally init their IDs, names and observed states (if provided as array-definitions).
boolReturn true if the given value is a DateTime or DateTimeInterface.
arrayStore a first variable as Carbon instance into the second variable if the first one is a date.
@codeCoverageIgnore
boolarrayGet stored data set for the a given holiday ID.
$this|nullSet stored data set for the a given holiday ID.
arrayGet stored data set for the current holiday or null if it's not a holiday.
$this|nullSet stored data set for the current holiday, does nothing if it's not a holiday.
Set the maximum of loop turns to run before throwing an exception where trying to add or subtract open/closed time.
intGet the maximum of loop turns to run before throwing an exception where trying to add or subtract open/closed time.
Carbon|CarbonImmutable|CarbonInterfaceShift 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|CarbonImmutable|CarbonInterfaceAdd the given interval taking into account only open time (if $open is true) or only closed time (if $open is false).
Carbon|CarbonImmutable|CarbonInterfaceAdd the given interval taking into account only open time (if $open is true) or only closed time (if $open is false).
Carbon|CarbonImmutable|CarbonInterfaceAdd the given interval taking into account only open time.
Carbon|CarbonImmutable|CarbonInterfaceSubtract the given interval taking into account only open time.
Carbon|CarbonImmutable|CarbonInterfaceAdd the given interval taking into account only closed time.
Carbon|CarbonImmutable|CarbonInterfaceSubtract the given interval taking into account only closed time.
Carbon|CarbonImmutable|CarbonInterfaceAdd the given number of minutes taking into account only open time.
Carbon|CarbonImmutable|CarbonInterfaceSubtract the given number of minutes taking into account only open time.
Carbon|CarbonImmutable|CarbonInterfaceAdd the given number of minutes taking into account only closed time.
Carbon|CarbonImmutable|CarbonInterfaceSubtract the given number of minutes taking into account only closed time.
Carbon|CarbonImmutable|CarbonInterfaceAdd the given number of hours taking into account only open time.
Carbon|CarbonImmutable|CarbonInterfaceSubtract the given number of hours taking into account only open time.
Carbon|CarbonImmutable|CarbonInterfaceAdd the given number of hours taking into account only closed time.
Carbon|CarbonImmutable|CarbonInterfaceSubtract the given number of hours taking into account only closed time.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
CarbonInterval|floatReturn an interval/count of given unit with open/closed business time between the current date and another given date.
CarbonIntervalReturn an interval with open/closed business time between the current date and another given date.
floatReturn a number of seconds with open/closed business time between the current date and another given date.
floatReturn a number of minutes with open/closed business time between the current date and another given date.
floatReturn a number of hours with open/closed business time between the current date and another given date.
Carbon|CarbonImmutable|CarbonInterfaceLoop on the current instance (or now if called statically) with a given method until it's not a holiday.
Carbon|CarbonImmutable|CarbonInterfaceLoop on the current instance (or now if called statically) with a given method until it's not a holiday.
Carbon|CarbonImmutable|CarbonInterfaceLoop on the current instance (or now if called statically) with a given method until it's not a holiday.
Carbon|CarbonImmutable|CarbonInterfaceLoop on the current instance (or now if called statically) with a given method until it's not a holiday.
Carbon|CarbonImmutable|CarbonInterfaceLoop on the current instance (or now if called statically) with a given method until it's not a holiday.
Carbon|CarbonImmutable|CarbonInterfaceLoop on the current instance (or now if called statically) with a given method until it's not a holiday.
Carbon|CarbonImmutable|CarbonInterfaceLoop on the current instance (or now if called statically) with a given method until it's not a holiday.
Carbon|CarbonImmutable|CarbonInterfaceLoop on the current instance (or now if called statically) with a given method until it's not a holiday.
boolReturns true if the business is open on a given day according to current opening hours.
boolReturns true if the business is open on a given day according to current opening hours.
boolReturns 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.
boolReturns 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.
boolReturns true if the business is open and not a holiday now (or current date and time) according to current opening hours.
boolReturns true if the business is open and not a holiday now (or current date and time) according to current opening hours.
boolReturns true if the business is closed or a holiday now (or current date and time) according to current opening hours.
boolReturns true if the business is closed or a holiday now (or current date and time) according to current opening hours.
Carbon|CarbonImmutable|CarbonInterface|boolGet 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|CarbonImmutable|CarbonInterface|boolGet 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|CarbonImmutable|CarbonInterface|boolGet 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|CarbonImmutable|CarbonInterface|boolGet 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|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Carbon|CarbonImmutable|CarbonInterfaceGet a method that return current date-time if $testMethod applied on it return true, else return the result of $method called on it.
Spatie\OpeningHours\OpeningHoursForDayGet OpeningHoursForDay instance of the current instance or class.
Spatie\OpeningHours\TimeRange[]Get open time ranges as array of TimeRange instances that matches the current date and time.
Spatie\OpeningHours\TimeRange|boolGet current open time range as TimeRange instance or false if closed.
CarbonPeriod|boolGet current open time range as TimeRange instance or false if closed.
Carbon|CarbonImmutable|CarbonInterface|boolGet 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|CarbonImmutable|CarbonInterface|boolGet 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|CarbonImmutable|CarbonInterface|boolGet 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|CarbonImmutable|CarbonInterface|boolGet 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.
Season\SeasonEnumReturn the season of the current date.
boolReturn either current date is in spring.
boolReturn either current date is in summer.
boolReturn either current date is in fall.
boolReturn either current date is in winter.
DateTimeZone|string|int $timezone
CarbonIntervalSet the instance's timezone from a string or object.
| Prototype changed | 3.0.0 | DateTimeZone|string|int $timezone |
| Method added | 2.52.0 | $tzName |
DateTimeZone|string|int $timezone
CarbonIntervalSet 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 |
arrayMapping of units and factors for cascading.
Should only be modified by changing the factors or referenced constants.
| Method added | 1.28.0 | no arguments |
array $cascadeFactors
Set default cascading factors for ->cascade() method.
| Method added | 1.28.0 | array $cascadeFactors |
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 |
$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 |
$source, $target
int|float|nullReturns the factor for a given source-to-target couple.
| Method added | 1.28.0 | $source, $target |
$source, $target
int|float|nullReturns 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 |
int|floatReturns current config for days per week.
| Method added | 1.28.0 | no arguments |
int|floatReturns current config for hours per day.
| Method added | 1.28.0 | no arguments |
int|floatReturns current config for minutes per hour.
| Method added | 2.0.0 | no arguments |
int|floatReturns current config for seconds per minute.
| Method added | 2.0.0 | no arguments |
int|floatReturns current config for microseconds per second.
| Method added | 2.0.0 | no arguments |
int|floatReturns current config for microseconds per second.
| Method added | 2.0.0 | no arguments |
$years = null, $months = null, $weeks = null, $days = null, $hours = null, $minutes = null, $seconds = null, $microseconds = null
CarbonIntervalCreate 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 |
string $format, ?string $interval
CarbonIntervalParse a string into a new CarbonInterval object according to the specified format.
Examples:
echo Carboninterval::createFromFormat('H:i', '1:30');
| Method added | 2.27.0 | string $format, ?string $interval |
array|int|string|DateInterval|mixed|nullReturn the original source used to create the current interval.
| Method added | 3.0.0 | no arguments |
CarbonInterfaceReturn the start date if interval was created from a difference between 2 dates.
| Method added | 3.0.0 | no arguments |
CarbonInterfaceReturn the end date if interval was created from a difference between 2 dates.
| Method added | 3.0.0 | no arguments |
CarbonIntervalGet rid of the original input, start date and end date that may be kept in memory.
| Method added | 3.0.0 | no arguments |
CarbonIntervalGet a copy of the instance.
| Method added | 1.28.0 | no arguments |
CarbonIntervalGet a copy of the instance.
| Method added | 2.22.0 | no arguments |
$dump
CarbonIntervalEvaluate 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 |
string $intervalDefinition
CarbonIntervalCreates 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 |
string $interval, ?string $locale = null
CarbonIntervalCreates 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 |
$start, $end = null, bool $absolute = false, array $skip = []
CarbonIntervalCreate an interval from the difference between 2 dates.
| Method added | 3.0.0 | $start, $end = null, bool $absolute = false, array $skip = [] |
bool $absolute = false
CarbonIntervalInvert the interval if it's inverted.
| Method added | 3.0.0 | bool $absolute = false |
bool $absolute = true
CarbonInterval@alias abs
Invert the interval if it's inverted.
| Method added | 3.0.0 | bool $absolute = true |
string $className
mixedCast the current instance into the given class.
| Method added | 2.23.0 | string $className |
DateInterval $interval, array $skip = [], bool $skipCopy = false
CarbonIntervalCreate 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 |
$interval, $unit = null, bool $skipCopy = false
CarbonIntervalMake 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 |
string $datetime
CarbonIntervalSets 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 |
Carbon\Unit|string $name
string|int|float|nullGet 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 |
string $name
string|int|float|nullGet a part of the CarbonInterval object.
| Prototype changed | 3.0.0 | string $name |
| Method added | 1.18.0 | $name |
$name, $value = null
CarbonIntervalSet a part of the CarbonInterval object.
| Method added | 2.37.0 | $name, $value = null |
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 |
int $weeks, int $days
CarbonIntervalAllow setting of weeks and days to be cumulative.
| Prototype changed | 3.0.0 | int $weeks, int $days |
| Method added | 1.18.0 | $weeks, $days |
boolReturns true if the interval is empty for each unit.
| Method added | 2.0.0 | no arguments |
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 |
$mixin
Register macros from a mixin object.
Examples:
CarbonInterval::mixin(new class {
public function daysToHours() {
return function () {
$this->hours += $this->days;
$this->days = 0;
return $this;
};
}
public function hoursToDays() {
return function () {
$this->days += $this->hours;
$this->hours = 0;
return $this;
};
}
});
echo CarbonInterval::hours(5)->hoursToDays() . "\n";
echo CarbonInterval::days(5)->daysToHours() . "\n";
| Method added | 1.28.0 | $mixin |
string $name
boolCheck if macro is registered.
| Prototype changed | 3.0.0 | string $name |
| Method added | 1.28.0 | $name |
arrayReturns interval values as an array where key are the unit names and values the counts.
| Method added | 2.27.0 | no arguments |
arrayReturns interval non-zero values as an array where key are the unit names and values the counts.
| Method added | 2.27.0 | no arguments |
arrayReturns 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 |
$syntax = null, $short = false, $parts = -1, $options = null
stringGet 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 |
string $format
stringReturns the formatted date string on success or FALSE on failure.
| Prototype changed | 1.21.0 | string $format |
| Method added | 1.18.0 | $format |
stringFormat the instance as a string using the forHumans() function.
| Method added | 1.18.0 | no arguments |
DateIntervalReturn 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 |
$params
CarbonPeriodConvert the interval to a CarbonPeriod.
| Prototype changed | 2.0.0 | $params |
| Method added | 1.29.0 | no arguments |
$interval, Carbon\Unit|string|null $unit = null
CarbonPeriodDecompose the current interval into
| Method added | 3.0.0 | $interval, Carbon\Unit|string|null $unit = null |
$inverted = null
CarbonIntervalInvert the interval.
| Prototype changed | 2.37.0 | $inverted = null |
| Method added | 1.28.0 | no arguments |
$unit, $value = 1
CarbonIntervalAdd the passed interval to the current instance.
| Prototype changed | 2.4.0 | $unit, $value = 1 |
| Method added | 1.18.0 | DateInterval $interval |
$unit, $value = 1
CarbonIntervalSubtract the passed interval to the current instance.
| Method added | 2.4.0 | $unit, $value = 1 |
$unit, $value = 1
CarbonIntervalSubtract the passed interval to the current instance.
| Method added | 2.4.0 | $unit, $value = 1 |
$years = 0, $months = 0, $weeks = 0, $days = 0, $hours = 0, $minutes = 0, $seconds = 0, $microseconds = 0
CarbonIntervalAdd 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 |
$years = 0, $months = 0, $weeks = 0, $days = 0, $hours = 0, $minutes = 0, $seconds = 0, $microseconds = 0
CarbonIntervalAdd 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 |
$factor
CarbonIntervalMultiply 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 |
$factor
CarbonIntervalMultiply and cascade current instance by a given factor.
| Method added | 2.20.0 | $factor |
$divider
CarbonIntervalDivide and cascade current instance by a given divider.
| Method added | 2.20.0 | $divider |
DateInterval $interval, bool $microseconds = false, array $skip = []
stringGet 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 |
bool $microseconds = false
stringGet the interval_spec string.
| Prototype changed | 2.61.0 | bool $microseconds = false |
| Method added | 1.22.0 | no arguments |
DateInterval $first, DateInterval $second
intComparing 2 date intervals.
| Prototype changed | 2.21.0 | DateInterval $first, DateInterval $second |
| Method added | 1.26.0 | DateInterval $a, DateInterval $b |
DateInterval $interval
intComparing with passed interval.
| Method added | 1.24.0 | DateInterval $interval |
CarbonIntervalConvert overflowed values into bigger units.
| Method added | 1.28.0 | no arguments |
bool| Method added | 2.37.0 | no arguments |
bool| Method added | 2.37.0 | no arguments |
string $unit
floatGet amount of given unit equivalent to the interval.
| Prototype changed | 3.0.0 | string $unit |
| Method added | 1.28.0 | $unit |
$interval
boolDetermines if the instance is equal to another
| Method added | 2.22.0 | $interval |
$interval
boolDetermines if the instance is equal to another
| Method added | 2.22.0 | $interval |
$interval
boolDetermines if the instance is not equal to another
| Method added | 2.22.0 | $interval |
$interval
boolDetermines if the instance is not equal to another
| Method added | 2.22.0 | $interval |
$interval
boolDetermines if the instance is greater (longer) than another
| Method added | 2.22.0 | $interval |
$interval
boolDetermines if the instance is greater (longer) than another
| Method added | 2.22.0 | $interval |
$interval
boolDetermines if the instance is greater (longer) than or equal to another
| Method added | 2.22.0 | $interval |
$interval
boolDetermines if the instance is greater (longer) than or equal to another
| Method added | 2.22.0 | $interval |
$interval
boolDetermines if the instance is less (shorter) than another
| Method added | 2.22.0 | $interval |
$interval
boolDetermines if the instance is less (shorter) than another
| Method added | 2.22.0 | $interval |
$interval
boolDetermines if the instance is less (shorter) than or equal to another
| Method added | 2.22.0 | $interval |
$interval
boolDetermines if the instance is less (shorter) than or equal to another
| Method added | 2.22.0 | $interval |
$interval1, $interval2, bool $equal = true
boolDetermines if the instance is between two others.
The third argument allow you to specify if bounds are included or not (true by default)
but for when you including/excluding bounds may produce different results in your application,
we recommend to use the explicit methods ->betweenIncluded() or ->betweenExcluded() instead.
Examples:
CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::days(3)); // true
CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::hours(36)); // false
CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::days(2)); // true
CarbonInterval::hours(48)->between(CarbonInterval::day(), CarbonInterval::days(2), false); // false
| Prototype changed | 3.0.0 | $interval1, $interval2, bool $equal = true |
| Method added | 2.22.0 | $interval1, $interval2, $equal = true |
$interval1, $interval2
boolDetermines if the instance is between two others, bounds excluded.
Examples:
CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::days(3)); // true
CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::hours(36)); // false
CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::days(2)); // true
| Method added | 2.31.0 | $interval1, $interval2 |
$interval1, $interval2
boolDetermines if the instance is between two others, bounds excluded.
Examples:
CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::days(3)); // true
CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::hours(36)); // false
CarbonInterval::hours(48)->betweenExcluded(CarbonInterval::day(), CarbonInterval::days(2)); // false
| Method added | 2.22.0 | $interval1, $interval2 |
$interval1, $interval2, bool $equal = true
boolDetermines if the instance is between two others
Examples:
CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::days(3)); // true
CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::hours(36)); // false
CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::days(2)); // true
CarbonInterval::hours(48)->isBetween(CarbonInterval::day(), CarbonInterval::days(2), false); // false
| Prototype changed | 3.0.0 | $interval1, $interval2, bool $equal = true |
| Method added | 2.22.0 | $interval1, $interval2, $equal = true |
string $unit, DateInterval|string|int|float $precision = 1, string $function = 'round'
CarbonIntervalRound 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' |
string $unit, $precision = 1
CarbonIntervalTruncate 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 |
string $unit, $precision = 1
CarbonIntervalCeil 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 |
$precision = 1, string $function = 'round'
CarbonIntervalRound 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' |
DateInterval|string|int|float $precision = 1
CarbonIntervalRound 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 |
DateInterval|string|int|float $precision = 1
CarbonIntervalCeil 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 |
array $data
Set locale if specified on unserialize() called.
Only used by PHP >= 7.4.
| Method added | 1.21.0 | array $data |
arrayWrapperClock| Method added | 3.0.0 | no arguments |
ClosureGet the dynamic step in use.
| Method added | 2.36.0 | no arguments |
?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 |
DateTimeInterface $dateTime, bool $negated = false
CarbonInterfaceTake 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 |
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 |
array $settings
CarbonIntervalSet 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 |
arrayReturns current local settings.
| Method added | 2.3.0 | no arguments |
arrayShow truthy properties on \Carbon\Doc\Generate\var_dump().
| Method added | 2.17.0 | no arguments |
bool $strictModeEnabled = true
| Prototype changed | 3.0.0 | bool $strictModeEnabled = true |
| Method added | 2.0.0 | $strictModeEnabled = true |
boolReturns 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 |
bool $monthsOverflow = true
| Prototype changed | 3.0.0 | bool $monthsOverflow = true |
| Method added | 2.0.0 | $monthsOverflow = true |
| Method added | 2.0.0 | no arguments |
boolGet the month overflow global behavior (can be overridden in specific instances).
| Method added | 2.0.0 | no arguments |
bool $yearsOverflow = true
| Prototype changed | 3.0.0 | bool $yearsOverflow = true |
| Method added | 2.0.0 | $yearsOverflow = true |
| Method added | 2.0.0 | no arguments |
boolGet the month overflow global behavior (can be overridden in specific instances).
| Method added | 2.0.0 | no arguments |
boolReturn true if the current instance has its own translator.
| Method added | 2.29.0 | no arguments |
Symfony\Contracts\Translation\TranslatorInterfaceGet the translator of the current instance or the default if none set.
| Method added | 2.0.0 | no arguments |
Symfony\Contracts\Translation\TranslatorInterface $translator
CarbonIntervalSet 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 |
$translator, string $key, ?string $locale = null, ?string $default = null
string|Closure|nullReturns raw translation message for a given key.
| Method added | 2.8.0 | $translator, string $key, ?string $locale = null, ?string $default = null |
string $key, ?string $locale = null, ?string $default = null, $translator = null
stringReturns raw translation message for a given key.
| Method added | 2.8.0 | string $key, ?string $locale = null, ?string $default = null, $translator = null |
Symfony\Contracts\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null
stringTranslate 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 |
string $key, array $parameters = [], string|int|float|null $number = null, ?Symfony\Contracts\Translation\TranslatorInterface $translator = null, bool $altNumbers = false
stringTranslate 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 |
int $number
stringReturns the alternative number for a given integer if available in the current locale.
| Method added | 2.23.0 | int $number |
string $timeString, ?string $from = null, ?string $to = null, int $mode = 31
stringTranslate 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 |
string $timeString, ?string $to = null
stringTranslate a time string from the current locale (`$date->locale()`) to another one.
| Prototype changed | 3.0.0 | string $timeString, ?string $to = null |
| Method added | 2.16.0 | $timeString, $to = null |
?string $locale = null, string $fallbackLocales
CarbonInterval|stringGet/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 |
stringGet the current translator locale.
| Method added | 1.18.0 | no arguments |
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 |
string $locale
Set the fallback locale.
| Prototype changed | 3.0.0 | string $locale |
| Method added | 2.16.0 | $locale |
stringGet the fallback locale.
| Method added | 2.16.0 | no arguments |
string $locale, callable $func
mixedSet 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 |
string $locale
boolReturns 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 |
string $locale
boolReturns 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 |
string $locale
boolReturns 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 |
string $locale
boolReturns 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 |
$locale
boolReturns 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 | 2.0.0 | $locale |
arrayReturns 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 |
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 |
int $humanDiffOptions
| Prototype changed | 3.0.0 | int $humanDiffOptions |
| Method added | 2.0.0 | $humanDiffOptions |
int $humanDiffOption
| Prototype changed | 3.0.0 | int $humanDiffOption |
| Method added | 2.0.0 | $humanDiffOption |
int $humanDiffOption
| Prototype changed | 3.0.0 | int $humanDiffOption |
| Method added | 2.0.0 | $humanDiffOption |
intReturn default humanDiff() options (merged flags as integer).
| Method added | 2.0.0 | no arguments |
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 |
Symfony\Contracts\Translation\TranslatorInterfaceInitialize the default translator instance if necessary.
| Method added | 1.18.0 | no arguments |
Reset the format used to the default when type juggling a Carbon instance to a string
| Method added | 2.63.0 | no arguments |
Closure|string|null $format
| Prototype changed | 3.0.0 | Closure|string|null $format |
| Method added | 2.63.0 | $format |
Generator| Method added | 3.0.0 | no arguments |
mixed $var
CarbonPeriodMake a CarbonPeriod instance from given variable if possible.
| Prototype changed | 3.0.0 | mixed $var |
| Method added | 2.22.0 | $var |
mixed $period
CarbonPeriodCreate a new instance from a DatePeriod or CarbonPeriod object.
| Prototype changed | 3.0.0 | mixed $period |
| Method added | 2.22.0 | $period |
$params
CarbonPeriodCreate a new instance.
| Prototype changed | 2.0.0 | $params |
| Method added | 1.29.0 | no arguments |
array $params
CarbonPeriodCreate a new instance from an array of parameters.
| Method added | 1.29.0 | array $params |
string $iso, ?int $options = null
CarbonPeriodCreate CarbonPeriod from ISO 8601 string.
| Prototype changed | 3.0.0 | string $iso, ?int $options = null |
| Method added | 1.29.0 | $iso, $options = null |
string $iso, ?int $options = null
CarbonPeriod| Prototype changed | 3.10.0 | string $iso, ?int $options = null |
| Method added | 3.0.0 | string $specification, int $options = 0 |
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 |
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 |
string $name
boolCheck if macro is registered.
| Prototype changed | 3.0.0 | string $name |
| Method added | 1.29.0 | $name |
$arguments
CarbonPeriod constructor.
| Prototype changed | 2.0.0 | $arguments |
| Method added | 1.29.0 | no arguments |
CarbonPeriodGet a copy of the instance.
| Method added | 2.22.0 | no arguments |
string $name
bool|CarbonInterface|CarbonInterval|int|nullGet a property allowing both `DatePeriod` snakeCase and camelCase names.
| Method added | 2.45.0 | string $name |
string $name
bool|CarbonInterface|CarbonInterval|int|nullGet a property allowing both `DatePeriod` snakeCase and camelCase names.
| Method added | 2.41.0 | string $name |
string $name
boolCheck if an attribute exists on the object
| Method added | 2.41.0 | string $name |
CarbonPeriod@alias copy
Get a copy of the instance.
| Method added | 2.22.0 | no arguments |
string $dateClass
CarbonPeriodSet the iteration item class.
| Method added | 2.0.0 | string $dateClass |
stringReturns iteration item date class.
| Method added | 2.0.0 | no arguments |
mixed $interval, Carbon\Unit|string|null $unit = null
CarbonPeriodChange the period date interval.
| Prototype changed | 3.0.0 | mixed $interval, Carbon\Unit|string|null $unit = null |
| Method added | 1.29.0 | $interval |
CarbonPeriodReset 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 |
CarbonPeriodInvert the period date interval.
| Method added | 1.29.0 | no arguments |
mixed $start, mixed $end
CarbonPeriodSet start and end date.
| Prototype changed | 3.0.0 | mixed $start, mixed $end |
| Method added | 1.29.0 | $start, $end |
?int $options
CarbonPeriodChange the period options.
| Prototype changed | 3.0.0 | ?int $options |
| Method added | 1.29.0 | $options |
intGet the period options.
| Method added | 1.29.0 | no arguments |
int $options, ?bool $state = null
CarbonPeriodToggle given options on or off.
| Prototype changed | 3.0.0 | int $options, ?bool $state = null |
| Method added | 1.29.0 | $options, $state = null |
bool $state = true
CarbonPeriodToggle EXCLUDE_START_DATE option.
| Prototype changed | 3.0.0 | bool $state = true |
| Method added | 1.29.0 | $state = true |
bool $state = true
CarbonPeriodToggle EXCLUDE_END_DATE option.
| Prototype changed | 3.0.0 | bool $state = true |
| Method added | 1.29.0 | $state = true |
CarbonIntervalGet the underlying date interval.
| Method added | 1.29.0 | no arguments |
?string $rounding = null
CarbonInterfaceGet start date of the period.
| Prototype changed | 2.23.0 | ?string $rounding = null |
| Method added | 1.29.0 | no arguments |
?string $rounding = null
CarbonInterfaceGet end date of the period.
| Prototype changed | 2.23.0 | ?string $rounding = null |
| Method added | 1.29.0 | no arguments |
int|float|nullGet number of recurrences.
| Method added | 1.29.0 | no arguments |
boolReturns true if the start date should be excluded.
| Method added | 1.29.0 | no arguments |
boolReturns true if the end date should be excluded.
| Method added | 1.29.0 | no arguments |
boolReturns true if the start date should be included.
| Method added | 2.23.0 | no arguments |
boolReturns true if the end date should be included.
| Method added | 2.23.0 | no arguments |
CarbonInterfaceReturn the start if it's included by option, else return the start + 1 period interval.
| Method added | 2.23.0 | no arguments |
CarbonInterfaceReturn 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 |
callable|string $callback, ?string $name = null
CarbonPeriodAdd a filter to the stack.
| Prototype changed | 3.0.0 | callable|string $callback, ?string $name = null |
| Method added | 1.29.0 | $callback, $name = null |
callable|string $callback, ?string $name = null
CarbonPeriodPrepend a filter to the stack.
| Prototype changed | 3.0.0 | callable|string $callback, ?string $name = null |
| Method added | 1.29.0 | $callback, $name = null |
callable|string $filter
CarbonPeriodRemove a filter by instance or name.
| Prototype changed | 3.0.0 | callable|string $filter |
| Method added | 1.29.0 | $filter |
callable|string $filter
boolReturn whether given instance or name is in the filter stack.
| Prototype changed | 3.0.0 | callable|string $filter |
| Method added | 1.29.0 | $filter |
arrayGet filters stack.
| Method added | 1.29.0 | no arguments |
array $filters
CarbonPeriodSet filters stack.
| Method added | 1.29.0 | array $filters |
CarbonPeriodReset filters stack.
| Method added | 1.29.0 | no arguments |
int|float|null $recurrences
CarbonPeriodAdd a recurrences filter (set maximum number of recurrences).
| Prototype changed | 3.0.0 | int|float|null $recurrences |
| Method added | 1.29.0 | $recurrences |
mixed $date, ?bool $inclusive = null
CarbonPeriodChange the period start date.
| Prototype changed | 3.0.0 | mixed $date, ?bool $inclusive = null |
| Method added | 1.29.0 | $date, $inclusive = null |
mixed $date, ?bool $inclusive = null
CarbonPeriodChange the period end date.
| Prototype changed | 3.0.0 | mixed $date, ?bool $inclusive = null |
| Method added | 1.29.0 | $date, $inclusive = null |
boolCheck if the current position is valid.
| Method added | 1.29.0 | no arguments |
intReturn the current key.
| Method added | 1.29.0 | no arguments |
CarbonInterfaceReturn the current date.
| Method added | 1.29.0 | no arguments |
Move forward to the next date.
| Method added | 1.29.0 | 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 |
int $count = 1
boolSkip 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 |
stringFormat the date period as ISO 8601.
| Method added | 1.29.0 | no arguments |
stringConvert the date period into a string.
| Method added | 1.29.0 | no arguments |
stringFormat the date period as ISO 8601.
| Method added | 1.29.0 | no arguments |
string $className
objectCast the current instance into the given class.
| Method added | 2.23.0 | string $className |
DatePeriodReturn 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 |
boolReturn `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 |
arrayConvert the date period into an array without changing current iteration state.
| Method added | 1.29.0 | no arguments |
intCount dates in the date period.
| Method added | 1.29.0 | no arguments |
CarbonInterfaceReturn the first date in the date period.
| Method added | 1.29.0 | no arguments |
CarbonInterfaceReturn the last date in the date period.
| Method added | 1.29.0 | no arguments |
stringConvert the date period into a string.
| Method added | 1.29.0 | no arguments |
DateTimeZone|string|int $timezone
CarbonPeriodSet 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 |
DateTimeZone|string|int $timezone
CarbonPeriodSet 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 |
?string $rounding = null
CarbonInterfaceReturns 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 |
mixed $rangeOrRangeStart, mixed $rangeEnd = null
boolReturns 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 |
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 |
callable $callback
GeneratorExecute 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 |
mixed $period
boolDetermines 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 |
mixed $period
boolDetermines 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 |
mixed $period
boolDetermines 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 |
mixed $period
boolDetermines 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 |
mixed $date = null
boolDetermines 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 |
mixed $date = null
boolDetermines 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 |
mixed $date = null
boolDetermines 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 |
mixed $date = null
boolDetermines 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 |
mixed $date = null
boolDetermines 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 |
mixed $date = null
boolDetermines 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 |
mixed $date = null
boolDetermines 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 |
mixed $date = null
boolDetermines 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 |
mixed $date = null
boolDetermines 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 |
mixed $date = null
boolDetermines 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 |
boolReturn true if start date is now or later. (Rather start/end are included by options is ignored.)
| Method added | 2.23.0 | no arguments |
boolReturn true if end date is now or later. (Rather start/end are included by options is ignored.)
| Method added | 2.23.0 | no arguments |
boolReturn 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 |
string $unit, DateInterval|string|int|float|null $precision = 1, callable|string $function = 'round'
CarbonPeriodRound 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' |
string $unit, DateInterval|string|int|float|null $precision = 1
CarbonPeriodTruncate 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 |
string $unit, DateInterval|string|int|float|null $precision = 1
CarbonPeriodCeil 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 |
DateInterval|string|int|float|null $precision = null, callable|string $function = 'round'
CarbonPeriodRound 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' |
DateInterval|string|int|float|null $precision = null
CarbonPeriodRound 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 |
DateInterval|string|int|float|null $precision = null
CarbonPeriodCeil 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 |
arraySpecify data which should be serialized to JSON.
| Method added | 2.23.0 | no arguments |
mixed $date = null
boolReturn 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 |
mixed $period, mixed $arguments
boolReturn 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 |
mixed $period, mixed $arguments
boolReturn 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 |
mixed $period, mixed $arguments
boolReturn 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 |
arrayShow truthy properties on \Carbon\Doc\Generate\var_dump().
| Method added | 2.17.0 | no arguments |
array $data
Set locale if specified on unserialize() called.
Only used by PHP >= 7.4.
| Method added | 3.0.0 | array $data |
arrayReturns the values to dump on serialize() called on.
Only used by PHP >= 7.4.
| Method added | 3.0.0 | no arguments |
Set locale if specified on unserialize() called.
Only used by PHP < 7.4.
| Method added | 3.0.0 | no arguments |
array $array
CarbonPeriodThe __set_state handler.
| Method added | 3.0.0 | array $array |
WrapperClock| Method added | 3.0.0 | no arguments |
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 |
array $settings
CarbonPeriodSet 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 |
arrayReturns current local settings.
| Method added | 2.3.0 | no arguments |
arrayShow truthy properties on \Carbon\Doc\Generate\var_dump().
| Method added | 3.0.0 | no arguments |
bool $strictModeEnabled = true
| Prototype changed | 3.0.0 | bool $strictModeEnabled = true |
| Method added | 2.0.0 | $strictModeEnabled = true |
boolReturns 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 |
bool $monthsOverflow = true
| Prototype changed | 3.0.0 | bool $monthsOverflow = true |
| Method added | 2.0.0 | $monthsOverflow = true |
| Method added | 2.0.0 | no arguments |
boolGet the month overflow global behavior (can be overridden in specific instances).
| Method added | 2.0.0 | no arguments |
bool $yearsOverflow = true
| Prototype changed | 3.0.0 | bool $yearsOverflow = true |
| Method added | 2.0.0 | $yearsOverflow = true |
| Method added | 2.0.0 | no arguments |
boolGet the month overflow global behavior (can be overridden in specific instances).
| Method added | 2.0.0 | no arguments |
boolReturn true if the current instance has its own translator.
| Method added | 2.29.0 | no arguments |
Symfony\Contracts\Translation\TranslatorInterfaceGet the translator of the current instance or the default if none set.
| Method added | 2.0.0 | no arguments |
Symfony\Contracts\Translation\TranslatorInterface $translator
CarbonPeriodSet 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 |
$translator, string $key, ?string $locale = null, ?string $default = null
string|Closure|nullReturns raw translation message for a given key.
| Method added | 2.8.0 | $translator, string $key, ?string $locale = null, ?string $default = null |
string $key, ?string $locale = null, ?string $default = null, $translator = null
stringReturns raw translation message for a given key.
| Method added | 2.8.0 | string $key, ?string $locale = null, ?string $default = null, $translator = null |
Symfony\Contracts\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null
stringTranslate 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 |
string $key, array $parameters = [], string|int|float|null $number = null, ?Symfony\Contracts\Translation\TranslatorInterface $translator = null, bool $altNumbers = false
stringTranslate 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 |
int $number
stringReturns the alternative number for a given integer if available in the current locale.
| Method added | 2.23.0 | int $number |
string $timeString, ?string $from = null, ?string $to = null, int $mode = 31
stringTranslate 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 |
string $timeString, ?string $to = null
stringTranslate a time string from the current locale (`$date->locale()`) to another one.
| Prototype changed | 3.0.0 | string $timeString, ?string $to = null |
| Method added | 2.16.0 | $timeString, $to = null |
?string $locale = null, string $fallbackLocales
CarbonPeriod|stringGet/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 |
stringGet the current translator locale.
| Method added | 2.0.0 | no arguments |
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 |
string $locale
Set the fallback locale.
| Prototype changed | 3.0.0 | string $locale |
| Method added | 2.16.0 | $locale |
stringGet the fallback locale.
| Method added | 2.16.0 | no arguments |
string $locale, callable $func
mixedSet 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 |
string $locale
boolReturns 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 |
string $locale
boolReturns 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 |
string $locale
boolReturns 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 |
string $locale
boolReturns 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 |
$locale
boolReturns 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 | 2.0.0 | $locale |
arrayReturns 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 |
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 |
int $humanDiffOptions
| Prototype changed | 3.0.0 | int $humanDiffOptions |
| Method added | 2.0.0 | $humanDiffOptions |
int $humanDiffOption
| Prototype changed | 3.0.0 | int $humanDiffOption |
| Method added | 2.0.0 | $humanDiffOption |
int $humanDiffOption
| Prototype changed | 3.0.0 | int $humanDiffOption |
| Method added | 2.0.0 | $humanDiffOption |
intReturn default humanDiff() options (merged flags as integer).
| Method added | 2.0.0 | no arguments |
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 |
Symfony\Contracts\Translation\TranslatorInterfaceInitialize the default translator instance if necessary.
| Method added | 2.0.0 | no arguments |
Reset the format used to the default when type juggling a Carbon instance to a string
| Method added | 2.63.0 | no arguments |
Closure|string|null $format
| Prototype changed | 3.0.0 | Closure|string|null $format |
| Method added | 2.63.0 | $format |
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 |
string $className
mixedCast the current instance into the given class.
| Method added | 2.23.0 | string $className |
DateTimeZone|string|int|false|null $object, DateTimeZone|string|int|false|null $objectDump = null
CarbonTimeZoneCreate 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 |
bool $dst = false
stringReturns 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 |
bool $dst = false
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 |
?DateTimeInterface $date = null
stringGet the offset as string "sHH:MM" (such as "+00:00" or "-12:30").
| Method added | 2.10.0 | ?DateTimeInterface $date = null |
?DateTimeInterface $date = null
CarbonTimeZoneReturns a new CarbonTimeZone object using the offset string instead of region string.
| Method added | 2.10.0 | ?DateTimeInterface $date = null |
?DateTimeInterface $date = null, int $isDST = 1
stringReturns 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 |
?DateTimeInterface $date = null
CarbonTimeZoneReturns a new CarbonTimeZone object using the region string instead of offset string.
| Method added | 2.10.0 | ?DateTimeInterface $date = null |
stringCast to string (get timezone name).
| Method added | 2.10.0 | no arguments |
intReturn 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 |
$object = null
false|CarbonTimeZoneCreate a CarbonTimeZone from mixed input.
| Method added | 2.0.0 | $object = null |
float $hourOffset
false|CarbonTimeZoneCreate a CarbonTimeZone from int/float hour offset.
| Method added | 2.33.0 | float $hourOffset |
float $minuteOffset
false|CarbonTimeZoneCreate a CarbonTimeZone from int/float minute offset.
| Method added | 2.33.0 | float $minuteOffset |
float $minutes
stringConvert a total minutes offset into a standardized timezone offset string.
| Method added | 2.33.0 | float $minutes |
arrayCarbonTimeZoneWrapperClock| Method added | 3.0.0 | no arguments |
?string $id, array $parameters = [], ?string $domain = null, ?string $locale = null
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 |
Symfony\Component\Translation\MessageCatalogueInterface $catalogue, string $id, string $domain = 'messages'
mixed@param mixed $translator
| Method added | 2.55.0 | Symfony\Component\Translation\MessageCatalogueInterface $catalogue, string $id, string $domain = 'messages' |
?string $locale = null
TranslatorReturn a singleton instance of Translator.
| Prototype changed | 3.0.0 | ?string $locale = null |
| Method added | 1.25.0 | $locale = null |
$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 |
arrayReturns the list of directories translation files are searched in.
| Method added | 2.0.0 | no arguments |
array $directories
TranslatorSet list of directories translation files are searched in.
| Method added | 2.0.0 | array $directories |
string $directory
TranslatorAdd a directory to the list translation files are searched in.
| Method added | 2.0.0 | string $directory |
string $directory
TranslatorRemove a directory from the list translation files are searched in.
| Method added | 2.0.0 | string $directory |
?string $locale = null
boolReset 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 |
string $prefix = ''
arrayReturns 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 = '' |
string $prefix = ''
arrayReturns 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 = '' |
string $locale, array $messages
TranslatorSet 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 |
array $messages
TranslatorSet messages of the current locale and take file first if present.
| Prototype changed | 3.0.0 | array $messages |
| Method added | 2.9.0 | $messages |
?string $locale = null
arrayGet 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 |
$locale
Set the current translator locale and indicate if the source locale file exists
| Method added | 1.25.0 | $locale |
arrayShow locale on \Carbon\Doc\Generate\var_dump().
| Method added | 2.17.0 | no arguments |
arrayReturns the values to dump on serialize() called on.
Only used by PHP >= 7.4.
| Method added | 3.3.1 | no arguments |
array $data
Set locale if specified on unserialize() called.
Only used by PHP >= 7.4.
| Method added | 3.3.1 | array $data |
See Symfony\Component\Translation\Translator::setConfigCacheFactory
See Symfony\Component\Translation\Translator::addLoader
See Symfony\Component\Translation\Translator::addResource
stringSee Symfony\Component\Translation\Translator::getLocale
See Symfony\Component\Translation\Translator::setFallbackLocales
arraySee Symfony\Component\Translation\Translator::getFallbackLocales
See Symfony\Component\Translation\Translator::addGlobalParameter
arraySee Symfony\Component\Translation\Translator::getGlobalParameters
Symfony\Component\Translation\MessageCatalogueInterfaceSee Symfony\Component\Translation\Translator::getCatalogue
arraySee Symfony\Component\Translation\Translator::getCatalogues
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 |
arrayGet the list of the known languages.
| Method added | 2.10.1 | no arguments |
arrayGet 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 |
arrayGet both isoName and nativeName as an array.
| Method added | 2.10.1 | no arguments |
stringReturns the original locale ID.
| Method added | 2.10.1 | no arguments |
stringReturns the code of the locale "en"/"fr".
| Method added | 2.10.1 | no arguments |
stringReturns the variant code such as cyrl/latn.
| Method added | 2.10.1 | no arguments |
stringReturns the variant such as Cyrillic/Latin.
| Method added | 2.10.1 | no arguments |
stringReturns the region part of the locale.
| Method added | 2.10.1 | no arguments |
stringReturns 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 |
stringReturns the long ISO language name.
| Method added | 2.10.1 | no arguments |
string $isoName
LanguageSet the ISO language name.
| Method added | 2.10.1 | string $isoName |
stringReturn the full name of the language in this language.
| Method added | 2.10.1 | no arguments |
string $nativeName
LanguageSet the name of the language in this language.
| Method added | 2.10.1 | string $nativeName |
stringReturns the short ISO language name.
| Method added | 2.10.1 | no arguments |
stringGet the short name of the language in this language.
| Method added | 2.10.1 | no arguments |
stringGet a string with short ISO name, region in parentheses if applicable, variant in parentheses if applicable.
| Method added | 2.10.1 | no arguments |
stringGet a string with short native name, region in parentheses if applicable, variant in parentheses if applicable.
| Method added | 2.10.1 | no arguments |
stringGet a string with long ISO name, region in parentheses if applicable, variant in parentheses if applicable.
| Method added | 2.10.1 | no arguments |
stringGet a string with long native name, region in parentheses if applicable, variant in parentheses if applicable.
| Method added | 2.10.1 | no arguments |
stringReturns the original locale ID.
| Method added | 2.10.1 | no arguments |
stringGet a string with short ISO name, region in parentheses if applicable, variant in parentheses if applicable.
| Method added | 2.10.1 | no arguments |
boolCheck if the current instance has UTC timezone. (Both isUtc and isUTC cases are valid.)
| Method added | 2.0.0 | no arguments |
boolCheck if the current instance has non-UTC timezone.
| Method added | 2.0.0 | no arguments |
boolCheck if the current instance is a valid date.
| Method added | 2.0.0 | no arguments |
boolCheck if the current instance is in a daylight saving time.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance day is sunday.
| Method added | 1.20.0 | no arguments |
boolChecks if the instance day is monday.
| Method added | 1.20.0 | no arguments |
boolChecks if the instance day is tuesday.
| Method added | 1.20.0 | no arguments |
boolChecks if the instance day is wednesday.
| Method added | 1.20.0 | no arguments |
boolChecks if the instance day is thursday.
| Method added | 1.20.0 | no arguments |
boolChecks if the instance day is friday.
| Method added | 1.20.0 | no arguments |
boolChecks if the instance day is saturday.
| Method added | 1.20.0 | no arguments |
DateTimeInterface|string $date
boolChecks 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 |
boolChecks if the instance is in the same year as the current moment.
| Method added | 1.22.0 | no arguments |
boolChecks if the instance is in the same year as the current moment next year.
| Method added | 1.22.0 | no arguments |
boolChecks if the instance is in the same year as the current moment last year.
| Method added | 1.22.0 | no arguments |
boolChecks 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 |
boolChecks if the instance is in the same month as the current moment next month.
| Method added | 1.22.0 | no arguments |
boolChecks if the instance is in the same month as the current moment last month.
| Method added | 1.22.0 | no arguments |
DateTimeInterface|string $date
boolChecks 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 |
boolChecks if the instance is in the same week as the current moment.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same week as the current moment next week.
| Method added | 1.22.0 | no arguments |
boolChecks if the instance is in the same week as the current moment last week.
| Method added | 1.22.0 | no arguments |
DateTimeInterface|string $date
boolChecks 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 |
boolChecks if the instance is in the same day as the current moment.
| Method added | 1.27.0 | no arguments |
boolChecks if the instance is in the same day as the current moment next day.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same day as the current moment last day.
| Method added | 2.0.0 | no arguments |
DateTimeInterface|string $date
boolChecks 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 |
boolChecks if the instance is in the same hour as the current moment.
| Method added | 1.27.0 | no arguments |
boolChecks if the instance is in the same hour as the current moment next hour.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same hour as the current moment last hour.
| Method added | 2.0.0 | no arguments |
DateTimeInterface|string $date
boolChecks 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 |
boolChecks if the instance is in the same minute as the current moment.
| Method added | 1.27.0 | no arguments |
boolChecks if the instance is in the same minute as the current moment next minute.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same minute as the current moment last minute.
| Method added | 2.0.0 | no arguments |
DateTimeInterface|string $date
boolChecks 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 |
boolChecks if the instance is in the same second as the current moment.
| Method added | 1.27.0 | no arguments |
boolChecks if the instance is in the same second as the current moment next second.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same second as the current moment last second.
| Method added | 2.0.0 | no arguments |
DateTimeInterface|string $date
boolChecks 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 |
boolChecks if the instance is in the same millisecond as the current moment.
| Method added | 3.0.0 | no arguments |
boolChecks if the instance is in the same millisecond as the current moment next millisecond.
| Method added | 3.0.0 | no arguments |
boolChecks if the instance is in the same millisecond as the current moment last millisecond.
| Method added | 3.0.0 | no arguments |
DateTimeInterface|string $date
boolChecks 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 |
boolChecks if the instance is in the same millisecond as the current moment.
| Method added | 3.0.0 | no arguments |
boolChecks if the instance is in the same millisecond as the current moment next millisecond.
| Method added | 3.0.0 | no arguments |
boolChecks if the instance is in the same millisecond as the current moment last millisecond.
| Method added | 3.0.0 | no arguments |
DateTimeInterface|string $date
boolChecks 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 |
boolChecks if the instance is in the same microsecond as the current moment.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same microsecond as the current moment next microsecond.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same microsecond as the current moment last microsecond.
| Method added | 2.0.0 | no arguments |
DateTimeInterface|string $date
boolChecks 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 |
boolChecks if the instance is in the same microsecond as the current moment.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same microsecond as the current moment next microsecond.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same microsecond as the current moment last microsecond.
| Method added | 2.0.0 | no arguments |
DateTimeInterface|string $date
boolChecks 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 |
boolChecks if the instance is in the same decade as the current moment.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same decade as the current moment next decade.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same decade as the current moment last decade.
| Method added | 2.0.0 | no arguments |
DateTimeInterface|string $date
boolChecks 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 |
boolChecks if the instance is in the same century as the current moment.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same century as the current moment next century.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same century as the current moment last century.
| Method added | 2.0.0 | no arguments |
DateTimeInterface|string $date
boolChecks 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 |
boolChecks if the instance is in the same millennium as the current moment.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same millennium as the current moment next millennium.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same millennium as the current moment last millennium.
| Method added | 2.0.0 | no arguments |
boolChecks if the instance is in the same quarter as the current moment.
| Method added | 1.26.4 | no arguments |
boolChecks if the instance is in the same quarter as the current moment next quarter.
| Method added | 1.26.4 | no arguments |
boolChecks if the instance is in the same quarter as the current moment last quarter.
| Method added | 1.26.4 | no arguments |
int $value
$thisSet current instance year to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance year to the given value.
| Prototype changed | 2.0.0 | int $value |
| Method added | 1.0.0 | $value |
int $value
$thisSet current instance year to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance year to the given value.
| Method added | 2.0.0 | int $value |
Month|int $value
$thisSet current instance month to the given value.
| Prototype changed | 3.0.0 | Month|int $value |
| Method added | 2.0.0 | int $value |
Month|int $value
$thisSet 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 |
Month|int $value
$thisSet current instance month to the given value.
| Prototype changed | 3.0.0 | Month|int $value |
| Method added | 2.0.0 | int $value |
Month|int $value
$thisSet current instance month to the given value.
| Prototype changed | 3.0.0 | Month|int $value |
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance day to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance day to the given value.
| Prototype changed | 2.0.0 | int $value |
| Method added | 1.0.0 | $value |
int $value
$thisSet current instance day to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance day to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance hour to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance hour to the given value.
| Prototype changed | 2.0.0 | int $value |
| Method added | 1.0.0 | $value |
int $value
$thisSet current instance hour to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance hour to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance minute to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance minute to the given value.
| Prototype changed | 2.0.0 | int $value |
| Method added | 1.0.0 | $value |
int $value
$thisSet current instance minute to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance minute to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance second to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance second to the given value.
| Prototype changed | 2.0.0 | int $value |
| Method added | 1.0.0 | $value |
int $value
$thisSet current instance second to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance second to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance millisecond to the given value.
| Method added | 2.7.0 | int $value |
int $value
$thisSet current instance millisecond to the given value.
| Method added | 2.7.0 | int $value |
int $value
$thisSet current instance millisecond to the given value.
| Method added | 2.7.0 | int $value |
int $value
$thisSet current instance millisecond to the given value.
| Method added | 2.7.0 | int $value |
int $value
$thisSet current instance millisecond to the given value.
| Method added | 2.7.0 | int $value |
int $value
$thisSet current instance millisecond to the given value.
| Method added | 2.7.0 | int $value |
int $value
$thisSet current instance millisecond to the given value.
| Method added | 2.7.0 | int $value |
int $value
$thisSet current instance millisecond to the given value.
| Method added | 2.7.0 | int $value |
int $value
$thisSet current instance microsecond to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance microsecond to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance microsecond to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance microsecond to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance microsecond to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance microsecond to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance microsecond to the given value.
| Method added | 2.0.0 | int $value |
int $value
$thisSet current instance microsecond to the given value.
| Method added | 2.0.0 | int $value |
int|float $value = 1
$thisAdd 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 |
$thisAdd 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 |
int|float $value = 1
$thisSub 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 |
$thisSub 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 |
int|float $value = 1
$thisAdd 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 |
$thisAdd 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 |
int|float $value = 1
$thisSub 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 |
$thisSub 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 |
int|float $value = 1
$thisAdd 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 |
$thisAdd one year to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one year to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one year to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one year to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd 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 |
int|float $value = 1
$thisSub 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 |
$thisSub 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 |
int|float $value = 1
$thisAdd 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 |
$thisAdd 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 |
int|float $value = 1
$thisSub 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 |
$thisSub 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 |
int|float $value = 1
$thisAdd 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 |
$thisAdd 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 |
int|float $value = 1
$thisSub 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 |
$thisSub 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 |
int|float $value = 1
$thisAdd 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 |
$thisAdd one month to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one month to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one month to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one month to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd 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 |
int|float $value = 1
$thisSub 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 |
$thisSub 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 |
int|float $value = 1
$thisAdd 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 |
$thisAdd 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 |
int|float $value = 1
$thisSub 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 |
$thisSub 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 |
int|float $value = 1
$thisAdd 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 |
$thisAdd 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 |
int|float $value = 1
$thisSub 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 |
$thisSub 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 |
int|float $value = 1
$thisAdd 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 |
$thisAdd 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 |
int|float $value = 1
$thisSub 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 |
$thisSub 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 |
int|float $value = 1
$thisAdd 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 |
$thisAdd 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 |
int|float $value = 1
$thisSub 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 |
$thisSub 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 |
int|float $value = 1
$thisAdd 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 |
$thisAdd one millisecond to the instance (using date interval).
| Method added | 2.6.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one millisecond to the instance (using date interval).
| Method added | 2.6.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one millisecond to the instance (using date interval).
| Method added | 2.6.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one millisecond to the instance (using date interval).
| Method added | 2.6.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one microsecond to the instance (using date interval).
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one microsecond to the instance (using date interval).
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one microsecond to the instance (using date interval).
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one microsecond to the instance (using date interval).
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one millennium to the instance (using date interval).
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one millennium to the instance (using date interval).
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one millennium to the instance (using date interval) with overflow explicitly allowed.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one millennium to the instance (using date interval) with overflow explicitly allowed.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one millennium to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one millennium to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one millennium to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one millennium to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one millennium to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one millennium to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one century to the instance (using date interval).
| Prototype changed | 2.0.0 | no arguments |
| Method added | 1.22.0 | $value = 1 |
int|float $value = 1
$thisSub 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 |
$thisSub one century to the instance (using date interval).
| Prototype changed | 2.0.0 | no arguments |
| Method added | 1.22.0 | $value = 1 |
int|float $value = 1
$thisAdd 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 |
$thisAdd one century to the instance (using date interval) with overflow explicitly allowed.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one century to the instance (using date interval) with overflow explicitly allowed.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one century to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one century to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one century to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one century to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one century to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one century to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one decade to the instance (using date interval).
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one decade to the instance (using date interval).
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one decade to the instance (using date interval) with overflow explicitly allowed.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one decade to the instance (using date interval) with overflow explicitly allowed.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one decade to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one decade to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one decade to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one decade to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one decade to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one decade to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one quarter to the instance (using date interval).
| Prototype changed | 2.0.0 | no arguments |
| Method added | 1.22.0 | $value = 1 |
int|float $value = 1
$thisSub 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 |
$thisSub one quarter to the instance (using date interval).
| Prototype changed | 2.0.0 | no arguments |
| Method added | 1.22.0 | $value = 1 |
int|float $value = 1
$thisAdd 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 |
$thisAdd one quarter to the instance (using date interval) with overflow explicitly allowed.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one quarter to the instance (using date interval) with overflow explicitly allowed.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one quarter to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one quarter to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one quarter to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one quarter to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd one quarter to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisSub 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 |
$thisSub one quarter to the instance (using date interval) with overflow explicitly forbidden.
| Method added | 2.0.0 | no arguments |
int|float $value = 1
$thisAdd 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 |
$thisAdd 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 |
int|float $value = 1
$thisSub 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 |
$thisSub 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 |
int|float $value = 1
$thisAdd 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 |
$thisAdd 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 |
int|float $value = 1
$thisSub 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 |
$thisSub 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 |
int|float $value = 1
$thisAdd microseconds (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one microsecond to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub microseconds (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one microsecond to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
int|float $value = 1
$thisAdd microseconds (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one microsecond to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub microseconds (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one microsecond to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
int|float $value = 1
$thisAdd milliseconds (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one millisecond to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub milliseconds (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one millisecond to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
int|float $value = 1
$thisAdd milliseconds (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one millisecond to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub milliseconds (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one millisecond to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
int|float $value = 1
$thisAdd seconds (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one second to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub seconds (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one second to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
int|float $value = 1
$thisAdd minutes (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one minute to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub minutes (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one minute to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
int|float $value = 1
$thisAdd hours (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one hour to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub hours (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one hour to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
int|float $value = 1
$thisAdd days (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one day to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub days (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one day to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
int|float $value = 1
$thisAdd weeks (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one week to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub weeks (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one week to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
int|float $value = 1
$thisAdd months (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one month to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub months (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one month to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
int|float $value = 1
$thisAdd quarters (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one quarter to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub quarters (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one quarter to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
int|float $value = 1
$thisAdd years (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one year to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub years (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one year to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
int|float $value = 1
$thisAdd decades (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one decade to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub decades (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one decade to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
int|float $value = 1
$thisAdd centuries (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one century to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub centuries (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one century to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
int|float $value = 1
$thisAdd millennia (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisAdd one millennium to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
int|float $value = 1
$thisSub millennia (the $value count passed in) to the instance (using timestamp).
| Method added | 3.2.0 | int|float $value = 1 |
$thisSub one millennium to the instance (using timestamp).
| Method added | 3.2.0 | no arguments |
$endDate = null, int|float $factor = 1
CarbonPeriodReturn 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 |
DateTimeInterface|string|null $date, bool $absolute = false
floatConvert 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 |
float $precision = 1, string $function = "round"
$thisRound the current instance year with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1, string $function = "round"
$thisRound the current instance year with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1
$thisTruncate the current instance year with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisTruncate the current instance year with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance year with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance year with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1, string $function = "round"
$thisRound the current instance month with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1, string $function = "round"
$thisRound the current instance month with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1
$thisTruncate the current instance month with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisTruncate the current instance month with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance month with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance month with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1, string $function = "round"
$thisRound the current instance day with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1, string $function = "round"
$thisRound the current instance day with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1
$thisTruncate the current instance day with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisTruncate the current instance day with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance day with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance day with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1, string $function = "round"
$thisRound the current instance hour with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1, string $function = "round"
$thisRound the current instance hour with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1
$thisTruncate the current instance hour with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisTruncate the current instance hour with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance hour with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance hour with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1, string $function = "round"
$thisRound the current instance minute with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1, string $function = "round"
$thisRound the current instance minute with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1
$thisTruncate the current instance minute with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisTruncate the current instance minute with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance minute with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance minute with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1, string $function = "round"
$thisRound the current instance second with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1, string $function = "round"
$thisRound the current instance second with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1
$thisTruncate the current instance second with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisTruncate the current instance second with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance second with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance second with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1, string $function = "round"
$thisRound the current instance millennium with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1, string $function = "round"
$thisRound the current instance millennium with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1
$thisTruncate the current instance millennium with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisTruncate the current instance millennium with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance millennium with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance millennium with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1, string $function = "round"
$thisRound the current instance century with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1, string $function = "round"
$thisRound the current instance century with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1
$thisTruncate the current instance century with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisTruncate the current instance century with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance century with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance century with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1, string $function = "round"
$thisRound the current instance decade with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1, string $function = "round"
$thisRound the current instance decade with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1
$thisTruncate the current instance decade with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisTruncate the current instance decade with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance decade with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance decade with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1, string $function = "round"
$thisRound the current instance quarter with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1, string $function = "round"
$thisRound the current instance quarter with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1
$thisTruncate the current instance quarter with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisTruncate the current instance quarter with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance quarter with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance quarter with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1, string $function = "round"
$thisRound the current instance millisecond with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1, string $function = "round"
$thisRound the current instance millisecond with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1
$thisTruncate the current instance millisecond with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisTruncate the current instance millisecond with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance millisecond with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance millisecond with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1, string $function = "round"
$thisRound the current instance microsecond with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1, string $function = "round"
$thisRound the current instance microsecond with given precision using the given function.
| Method added | 2.0.0 | float $precision = 1, string $function = "round" |
float $precision = 1
$thisTruncate the current instance microsecond with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisTruncate the current instance microsecond with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance microsecond with given precision.
| Method added | 2.0.0 | float $precision = 1 |
float $precision = 1
$thisCeil the current instance microsecond with given precision.
| Method added | 2.0.0 | float $precision = 1 |
DateTimeInterface $other = null, int $parts = 1
stringGet 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 |
DateTimeInterface $other = null, int $parts = 1
stringGet 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 |
DateTimeInterface $other = null, int $parts = 1
stringGet 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 |
DateTimeInterface $other = null, int $parts = 1
stringGet 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 |
DateTimeInterface $other = null, int $parts = 1
stringGet 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 |
DateTimeInterface $other = null, int $parts = 1
stringGet 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 |
DateTimeInterface $other = null, int $parts = 1
stringGet 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 |
DateTimeInterface $other = null, int $parts = 1
stringGet 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 |
intReturn the number of centuries contained in the current millennium
| Method added | 3.0.0 | no arguments |
?int $century = null
int|staticReturn 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 |
?int $day = null
int|staticReturn 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 |
?int $day = null
int|staticReturn 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 |
?int $day = null
int|staticReturn 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 |
?int $day = null
int|staticReturn 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 |
?int $day = null
int|staticReturn 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 |
?int $day = null
int|staticReturn 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 |
intReturn the number of days contained in the current century
| Method added | 3.0.0 | no arguments |
intReturn the number of days contained in the current decade
| Method added | 3.0.0 | no arguments |
intReturn the number of days contained in the current millennium
| Method added | 3.0.0 | no arguments |
intReturn the number of days contained in the current month
| Method added | 3.0.0 | no arguments |
intReturn the number of days contained in the current quarter
| Method added | 3.0.0 | no arguments |
intReturn the number of days contained in the current week
| Method added | 3.0.0 | no arguments |
intReturn the number of days contained in the current year
| Method added | 3.0.0 | no arguments |
?int $decade = null
int|staticReturn 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 |
?int $decade = null
int|staticReturn 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 |
intReturn the number of decades contained in the current century
| Method added | 3.0.0 | no arguments |
intReturn the number of decades contained in the current millennium
| Method added | 3.0.0 | no arguments |
?int $hour = null
int|staticReturn 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 |
?int $hour = null
int|staticReturn 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 |
?int $hour = null
int|staticReturn 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 |
?int $hour = null
int|staticReturn 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 |
?int $hour = null
int|staticReturn 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 |
?int $hour = null
int|staticReturn 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 |
?int $hour = null
int|staticReturn 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 |
?int $hour = null
int|staticReturn 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 |
intReturn the number of hours contained in the current century
| Method added | 3.0.0 | no arguments |
intReturn the number of hours contained in the current day
| Method added | 3.0.0 | no arguments |
intReturn the number of hours contained in the current decade
| Method added | 3.0.0 | no arguments |
intReturn the number of hours contained in the current millennium
| Method added | 3.0.0 | no arguments |
intReturn the number of hours contained in the current month
| Method added | 3.0.0 | no arguments |
intReturn the number of hours contained in the current quarter
| Method added | 3.0.0 | no arguments |
intReturn the number of hours contained in the current week
| Method added | 3.0.0 | no arguments |
intReturn the number of hours contained in the current year
| Method added | 3.0.0 | no arguments |
?int $microsecond = null
int|staticReturn 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 |
?int $microsecond = null
int|staticReturn 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 |
?int $microsecond = null
int|staticReturn 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 |
?int $microsecond = null
int|staticReturn 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 |
?int $microsecond = null
int|staticReturn 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 |
?int $microsecond = null
int|staticReturn 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 |
?int $microsecond = null
int|staticReturn 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 |
?int $microsecond = null
int|staticReturn 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 |
?int $microsecond = null
int|staticReturn 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 |
?int $microsecond = null
int|staticReturn 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 |
?int $microsecond = null
int|staticReturn 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 |
?int $microsecond = null
int|staticReturn 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 |
intReturn the number of microseconds contained in the current century
| Method added | 3.0.0 | no arguments |
intReturn the number of microseconds contained in the current day
| Method added | 3.0.0 | no arguments |
intReturn the number of microseconds contained in the current decade
| Method added | 3.0.0 | no arguments |
intReturn the number of microseconds contained in the current hour
| Method added | 3.0.0 | no arguments |
intReturn the number of microseconds contained in the current millennium
| Method added | 3.0.0 | no arguments |
intReturn the number of microseconds contained in the current millisecond
| Method added | 3.0.0 | no arguments |
intReturn the number of microseconds contained in the current minute
| Method added | 3.0.0 | no arguments |
intReturn the number of microseconds contained in the current month
| Method added | 3.0.0 | no arguments |
intReturn the number of microseconds contained in the current quarter
| Method added | 3.0.0 | no arguments |
intReturn the number of microseconds contained in the current second
| Method added | 3.0.0 | no arguments |
intReturn the number of microseconds contained in the current week
| Method added | 3.0.0 | no arguments |
intReturn the number of microseconds contained in the current year
| Method added | 3.0.0 | no arguments |
?int $millisecond = null
int|staticReturn 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 |
?int $millisecond = null
int|staticReturn 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 |
?int $millisecond = null
int|staticReturn 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 |
?int $millisecond = null
int|staticReturn 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 |
?int $millisecond = null
int|staticReturn 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 |
?int $millisecond = null
int|staticReturn 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 |
?int $millisecond = null
int|staticReturn 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 |
?int $millisecond = null
int|staticReturn 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 |
?int $millisecond = null
int|staticReturn 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 |
?int $millisecond = null
int|staticReturn 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 |
?int $millisecond = null
int|staticReturn 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 |
intReturn the number of milliseconds contained in the current century
| Method added | 3.0.0 | no arguments |
intReturn the number of milliseconds contained in the current day
| Method added | 3.0.0 | no arguments |
intReturn the number of milliseconds contained in the current decade
| Method added | 3.0.0 | no arguments |
intReturn the number of milliseconds contained in the current hour
| Method added | 3.0.0 | no arguments |
intReturn the number of milliseconds contained in the current millennium
| Method added | 3.0.0 | no arguments |
intReturn the number of milliseconds contained in the current minute
| Method added | 3.0.0 | no arguments |
intReturn the number of milliseconds contained in the current month
| Method added | 3.0.0 | no arguments |
intReturn the number of milliseconds contained in the current quarter
| Method added | 3.0.0 | no arguments |
intReturn the number of milliseconds contained in the current second
| Method added | 3.0.0 | no arguments |
intReturn the number of milliseconds contained in the current week
| Method added | 3.0.0 | no arguments |
intReturn the number of milliseconds contained in the current year
| Method added | 3.0.0 | no arguments |
?int $minute = null
int|staticReturn 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 |
?int $minute = null
int|staticReturn 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 |
?int $minute = null
int|staticReturn 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 |
?int $minute = null
int|staticReturn 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 |
?int $minute = null
int|staticReturn 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 |
?int $minute = null
int|staticReturn 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 |
?int $minute = null
int|staticReturn 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 |
?int $minute = null
int|staticReturn 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 |
?int $minute = null
int|staticReturn 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 |
intReturn the number of minutes contained in the current century
| Method added | 3.0.0 | no arguments |
intReturn the number of minutes contained in the current day
| Method added | 3.0.0 | no arguments |
intReturn the number of minutes contained in the current decade
| Method added | 3.0.0 | no arguments |
intReturn the number of minutes contained in the current hour
| Method added | 3.0.0 | no arguments |
intReturn the number of minutes contained in the current millennium
| Method added | 3.0.0 | no arguments |
intReturn the number of minutes contained in the current month
| Method added | 3.0.0 | no arguments |
intReturn the number of minutes contained in the current quarter
| Method added | 3.0.0 | no arguments |
intReturn the number of minutes contained in the current week
| Method added | 3.0.0 | no arguments |
intReturn the number of minutes contained in the current year
| Method added | 3.0.0 | no arguments |
?int $month = null
int|staticReturn 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 |
?int $month = null
int|staticReturn 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 |
?int $month = null
int|staticReturn 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 |
?int $month = null
int|staticReturn 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 |
?int $month = null
int|staticReturn 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 |
intReturn the number of months contained in the current century
| Method added | 3.0.0 | no arguments |
intReturn the number of months contained in the current decade
| Method added | 3.0.0 | no arguments |
intReturn the number of months contained in the current millennium
| Method added | 3.0.0 | no arguments |
intReturn the number of months contained in the current quarter
| Method added | 3.0.0 | no arguments |
intReturn the number of months contained in the current year
| Method added | 3.0.0 | no arguments |
?int $quarter = null
int|staticReturn 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 |
?int $quarter = null
int|staticReturn 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 |
?int $quarter = null
int|staticReturn 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 |
?int $quarter = null
int|staticReturn 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 |
intReturn the number of quarters contained in the current century
| Method added | 3.0.0 | no arguments |
intReturn the number of quarters contained in the current decade
| Method added | 3.0.0 | no arguments |
intReturn the number of quarters contained in the current millennium
| Method added | 3.0.0 | no arguments |
intReturn the number of quarters contained in the current year
| Method added | 3.0.0 | no arguments |
?int $second = null
int|staticReturn 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 |
?int $second = null
int|staticReturn 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 |
?int $second = null
int|staticReturn 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 |
?int $second = null
int|staticReturn 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 |
?int $second = null
int|staticReturn 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 |
?int $second = null
int|staticReturn 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 |
?int $second = null
int|staticReturn 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 |
?int $second = null
int|staticReturn 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 |
?int $second = null
int|staticReturn 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 |
?int $second = null
int|staticReturn 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 |
intReturn the number of seconds contained in the current century
| Method added | 3.0.0 | no arguments |
intReturn the number of seconds contained in the current day
| Method added | 3.0.0 | no arguments |
intReturn the number of seconds contained in the current decade
| Method added | 3.0.0 | no arguments |
intReturn the number of seconds contained in the current hour
| Method added | 3.0.0 | no arguments |
intReturn the number of seconds contained in the current millennium
| Method added | 3.0.0 | no arguments |
intReturn the number of seconds contained in the current minute
| Method added | 3.0.0 | no arguments |
intReturn the number of seconds contained in the current month
| Method added | 3.0.0 | no arguments |
intReturn the number of seconds contained in the current quarter
| Method added | 3.0.0 | no arguments |
intReturn the number of seconds contained in the current week
| Method added | 3.0.0 | no arguments |
intReturn the number of seconds contained in the current year
| Method added | 3.0.0 | no arguments |
?int $week = null
int|staticReturn 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 |
?int $week = null
int|staticReturn 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 |
?int $week = null
int|staticReturn 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 |
?int $week = null
int|staticReturn 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 |
?int $week = null
int|staticReturn 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 |
?int $week = null
int|staticReturn 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 |
intReturn the number of weeks contained in the current century
| Method added | 3.0.0 | no arguments |
intReturn the number of weeks contained in the current decade
| Method added | 3.0.0 | no arguments |
intReturn the number of weeks contained in the current millennium
| Method added | 3.0.0 | no arguments |
intReturn the number of weeks contained in the current month
| Method added | 3.0.0 | no arguments |
intReturn the number of weeks contained in the current quarter
| Method added | 3.0.0 | no arguments |
?int $year = null
int|staticReturn 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 |
?int $year = null
int|staticReturn 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 |
?int $year = null
int|staticReturn 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 |
intReturn the number of years contained in the current century
| Method added | 3.0.0 | no arguments |
intReturn the number of years contained in the current decade
| Method added | 3.0.0 | no arguments |
intReturn the number of years contained in the current millennium
| Method added | 3.0.0 | no arguments |