Menu

## CarbonInterface extends DateTimeInterface, JsonSerializable
in

CarbonInterface.php : 854

Common interface for Carbon and CarbonImmutable.

<autodoc generated by `composer phpdoc`>

##### Tags

codeCoverageIgnore

### Table of Contents

#### Constants

APRIL = 4
AUGUST = 8
CEIL = 0200
DAYS_PER_WEEK = 7
DAYS_PER_YEAR = 365
DECEMBER = 12
DEFAULT_LOCALE = 'en'
  Default locale (language and region).
DEFAULT_TO_STRING_FORMAT = 'Y-m-d H:i:s'
  Default format to use for __toString method when type juggling occurs.
DIFF_ABSOLUTE = 1
  Diff syntax options.
DIFF_RELATIVE_AUTO = 0
DIFF_RELATIVE_TO_NOW = 2
DIFF_RELATIVE_TO_OTHER = 3
FEBRUARY = 2
FLOOR = 0100
FRIDAY = 5
HOURS_PER_DAY = 24
ISO_FORMAT_REGEXP = '(O[YMDHhms]|[Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY?|g{1,5}|G{1,5}|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?)'
  Pattern detection for ->isoFormat and ::createFromIsoFormat.
JANUARY = 1
  The month constants.
JULY = 7
JUNE = 6
JUST_NOW = 02
MARCH = 3
MAY = 5
MICROSECONDS_PER_MILLISECOND = 1000
MICROSECONDS_PER_SECOND = 1000000
MILLISECONDS_PER_SECOND = 1000
MINUTES_PER_HOUR = 60
MOCK_DATETIME_FORMAT = 'Y-m-d H:i:s.u'
  Format for converting mocked time, includes microseconds.
MONDAY = 1
MONTHS_PER_QUARTER = 3
MONTHS_PER_YEAR = 12
NO_ZERO_DIFF = 01
  Diff wording options(expressed in octal).
NOVEMBER = 11
OCTOBER = 10
ONE_DAY_WORDS = 04
QUARTERS_PER_YEAR = 4
RFC7231_FORMAT = 'D, d M Y H:i:s \\G\\M\\T'
  RFC7231 DateTime format.
ROUND = 040
SATURDAY = 6
SECONDS_PER_MINUTE = 60
SEPTEMBER = 9
SEQUENTIAL_PARTS_ONLY = 020
SUNDAY = 0
  The day constants.
THURSDAY = 4
TRANSLATE_ALL = self::TRANSLATE_MONTHS | self::TRANSLATE_DAYS | self::TRANSLATE_UNITS | self::TRANSLATE_MERIDIEM | self::TRANSLATE_DIFF
TRANSLATE_DAYS = 2
TRANSLATE_DIFF = 0x10
TRANSLATE_MERIDIEM = 8
TRANSLATE_MONTHS = 1
  Translate string options.
TRANSLATE_UNITS = 4
TUESDAY = 2
TWO_DAY_WORDS = 010
WEDNESDAY = 3
WEEK_DAY_AUTO = 'auto'
  Special settings to get the start of week from current locale culture.
WEEKS_PER_MONTH = 4
WEEKS_PER_YEAR = 52
YEARS_PER_CENTURY = 100
YEARS_PER_DECADE = 10
YEARS_PER_MILLENNIUM = 1000
  Number of X in Y.

#### Methods

__call() : mixed
  Dynamically handle calls to the class.
__callStatic() : mixed
  Dynamically handle calls to the class.
__clone() : void
  Update constructedObjectId on cloned.
__construct() : mixed
  Create a new Carbon instance.
__debugInfo() : array<string|int, mixed>
  Show truthy properties on var_dump().
__get() : string|int|bool|DateTimeZone|null
  Get a part of the Carbon object.
__isset() : bool
  Check if an attribute exists on the object
__set() : void
  Set a part of the Carbon object
__set_state() : static
  The __set_state handler.
__sleep() : array<string|int, mixed>
  Returns the list of properties to dump on serialize() called on.
__toString() : mixed
  Format the instance as a string using the set format
add() : static
  Add given units or interval to the current instance.
addRealUnit() : static
addUnit() : static
  Add given units to the current instance.
addUnitNoOverflow() : static
  Add any unit to a new value without overflowing current other unit given.
addUTCUnit() : static
  Add seconds to the instance using timestamp. Positive $value travels forward while negative $value travels into the past.
ago() : string
  Get the difference in a human readable format in the current locale from an other instance given to now
average() : static
  Modify the current instance to the average of a given instance (default now) and the current instance (second-precision).
avoidMutation() : static
  Clone the current instance if it's mutable.
between() : bool
  Determines if the instance is between two others.
betweenExcluded() : bool
  Determines if the instance is between two others, bounds excluded.
betweenIncluded() : bool
  Determines if the instance is between two others, bounds included.
calendar() : string
  Returns either day of week + time (e.g. "Last Friday at 3:30 PM") if reference time is within 7 days, or a calendar date (e.g. "10/29/2017") otherwise.
canBeCreatedFromFormat() : bool
  Checks if the (date)time string is in a given format and valid to create a new instance.
carbonize() : static
  Return the Carbon instance passed through, a now instance in the same timezone if null given or parse the input if string given.
cast() : T
  Cast the current instance into the given class.
ceil() : static
  Ceil the current instance second with given precision if specified.
ceilUnit() : static
  Ceil the current instance at the given unit with given precision if specified.
ceilWeek() : static
  Ceil the current instance week.
change() : static
  Similar to native modify() method of DateTime but can handle more grammars.
cleanupDumpProperties() : mixed
  Cleanup properties attached to the public scope of DateTime when a dump of the date is requested.
clone() : static
closest() : static
  Get the closest date from the instance (second-precision).
copy() : static
  Get a copy of the instance.
create() : static|null
  Create a new Carbon instance from a specific date and time.
createFromDate() : static
  Create a Carbon instance from just a date. The time portion is set to now.
createFromFormat() : static|null
  Create a Carbon instance from a specific format.
createFromIsoFormat() : static|null
  Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).
createFromLocaleFormat() : static|null
  Create a Carbon instance from a specific format and a string in a given language.
createFromLocaleIsoFormat() : static|null
  Create a Carbon instance from a specific ISO format and a string in a given language.
createFromTime() : static
  Create a Carbon instance from just a time. The date portion is set to today.
createFromTimestamp() : static
  Create a Carbon instance from a timestamp and set the timezone (UTC by default).
createFromTimestampMs() : static
  Create a Carbon instance from a timestamp in milliseconds.
createFromTimestampMsUTC() : static
  Create a Carbon instance from a timestamp in milliseconds.
createFromTimestampUTC() : static
  Create a Carbon instance from a timestamp keeping the timezone to UTC.
createFromTimeString() : static
  Create a Carbon instance from a time string. The date portion is set to today.
createMidnightDate() : static
  Create a Carbon instance from just a date. The time portion is set to midnight.
createSafe() : static|null
  Create a new safe Carbon instance from a specific date and time.
createStrict() : static
  Create a new Carbon instance from a specific date and time using strict validation.
dayOfYear() : static|int
  Get/set the day of year.
diffAsCarbonInterval() : CarbonInterval
  Get the difference as a CarbonInterval instance.
diffAsDateInterval() : DateInterval
  Get the difference as a DateInterval instance.
diffFiltered() : int
  Get the difference by the given interval using a filter closure.
diffForHumans() : string
  Get the difference in a human readable format in the current locale from current instance to an other instance given (or now if null given).
diffInDays() : float
  Get the difference in days.
diffInDaysFiltered() : int
  Get the difference in days using a filter closure.
diffInHours() : float
  Get the difference in hours.
diffInHoursFiltered() : int
  Get the difference in hours using a filter closure.
diffInMicroseconds() : float
  Get the difference in microseconds.
diffInMilliseconds() : float
  Get the difference in milliseconds.
diffInMinutes() : float
  Get the difference in minutes.
diffInMonths() : float
  Get the difference in months.
diffInQuarters() : float
  Get the difference in quarters.
diffInSeconds() : float
  Get the difference in seconds.
diffInUnit() : float
diffInWeekdays() : int
  Get the difference in weekdays.
diffInWeekendDays() : int
  Get the difference in weekend days using a filter.
diffInWeeks() : float
  Get the difference in weeks.
diffInYears() : float
  Get the difference in years
disableHumanDiffOption() : void
enableHumanDiffOption() : void
endOf() : static
  Modify to end of current given unit.
endOfCentury() : static
  Resets the date to end of the century and time to 23:59:59.999999
endOfDay() : static
  Resets the time to 23:59:59.999999 end of day
endOfDecade() : static
  Resets the date to end of the decade and time to 23:59:59.999999
endOfHour() : static
  Modify to end of current hour, minutes and seconds become 59
endOfMillennium() : static
  Resets the date to end of the millennium and time to 23:59:59.999999
endOfMillisecond() : static
  Modify to end of current millisecond, microseconds such as 12345 become 123999
endOfMinute() : static
  Modify to end of current minute, seconds become 59
endOfMonth() : static
  Resets the date to end of the month and time to 23:59:59.999999
endOfQuarter() : static
  Resets the date to end of the quarter and time to 23:59:59.999999
endOfSecond() : static
  Modify to end of current second, microseconds become 999999
endOfWeek() : static
  Resets the date to end of week (defined in $weekEndsAt) and time to 23:59:59.999999
endOfYear() : static
  Resets the date to end of the year and time to 23:59:59.999999
eq() : bool
  Determines if the instance is equal to another
equalTo() : bool
  Determines if the instance is equal to another
executeWithLocale() : mixed
  Set the current locale to the given, execute the passed function, reset the locale to previous one, then return the result of the closure (or null if the closure was void).
farthest() : static
  Get the farthest date from the instance (second-precision).
firstOfMonth() : static
  Modify to the first occurrence of a given day of the week in the current month. If no dayOfWeek is provided, modify to the first day of the current month. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
firstOfQuarter() : static
  Modify to the first occurrence of a given day of the week in the current quarter. If no dayOfWeek is provided, modify to the first day of the current quarter. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
firstOfYear() : static
  Modify to the first occurrence of a given day of the week in the current year. If no dayOfWeek is provided, modify to the first day of the current year. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
floor() : static
  Round the current instance second with given precision if specified.
floorUnit() : static
  Truncate the current instance at the given unit with given precision if specified.
floorWeek() : static
  Truncate the current instance week.
from() : string
fromNow() : string
  Get the difference in a human readable format in the current locale from current instance to now.
fromSerialized() : static
  Create an instance from a serialized string.
genericMacro() : void
  Register a custom macro.
get() : string|int|bool|DateTimeZone
  Get a part of the Carbon object.
getAltNumber() : string
  Returns the alternative number for a given date property if available in the current locale.
getAvailableLocales() : array<string|int, mixed>
  Returns the list of internally available locales and already loaded custom locales.
getAvailableLocalesInfo() : array<string|int, 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.
getCalendarFormats() : array<string|int, mixed>
  Returns list of calendar formats for ISO formatting.
getClock() : WrapperClock|null
getDays() : array<string|int, mixed>
  Get the days of the week.
getDaysFromStartOfWeek() : int
  Return the number of days since the start of the week (using the current locale or the first parameter if explicitly given).
getFallbackLocale() : string|null
  Get the fallback locale.
getFormatsToIsoReplacements() : array<string|int, mixed>
  List of replacements from date() format to isoFormat().
getHumanDiffOptions() : int
  Return default humanDiff() options (merged flags as integer).
getIsoFormats() : array<string|int, mixed>
  Returns list of locale formats for ISO formatting.
getIsoUnits() : array<string|int, mixed>
  Returns list of locale units for ISO formatting.
getLastErrors() : array<string|int, mixed>|false
  {@inheritdoc}
getLocale() : string
  Get the current translator locale.
getLocalMacro() : callable|null
  Get the raw callable macro registered globally or locally for a given name.
getLocalTranslator() : TranslatorInterface
  Get the translator of the current instance or the default if none set.
getMacro() : callable|null
  Get the raw callable macro registered globally for a given name.
getMidDayAt() : int
  get midday/noon hour
getOffsetString() : string
  Returns the offset hour and minute formatted with +/- and a given separator (":" by default).
getPaddedUnit() : string
  Returns a unit of the instance padded with 0 by default or any other string if specified.
getPreciseTimestamp() : float
  Returns a timestamp rounded with the given precision (6 by default).
getSettings() : array<string|int, mixed>
  Returns current local settings.
getTestNow() : Closure|self|null
  Get the Carbon instance (real or mock) to be returned when a "now" instance is created.
getTimeFormatByPrecision() : string
  Return a format from H:i to H:i:s.u according to given unit precision.
getTimestampMs() : int
  Returns the timestamp with millisecond precision.
getTranslatedDayName() : string
  Get the translation of the current week day name (with context for languages with multiple forms).
getTranslatedMinDayName() : string
  Get the translation of the current abbreviated week day name (with context for languages with multiple forms).
getTranslatedMonthName() : string
  Get the translation of the current month day name (with context for languages with multiple forms).
getTranslatedShortDayName() : string
  Get the translation of the current short week day name (with context for languages with multiple forms).
getTranslatedShortMonthName() : string
  Get the translation of the current short month day name (with context for languages with multiple forms).
getTranslationMessage() : string
  Returns raw translation message for a given key.
getTranslationMessageWith() : string|Closure|null
  Returns raw translation message for a given key.
getTranslator() : TranslatorInterface
  Initialize the default translator instance if necessary.
getWeekendDays() : array<string|int, mixed>
  Get weekend days
getWeekEndsAt() : int
  Get the last day of week.
getWeekStartsAt() : int
  Get the first day of week.
greaterThan() : bool
  Determines if the instance is greater (after) than another
greaterThanOrEqualTo() : bool
  Determines if the instance is greater (after) than or equal to another
gt() : bool
  Determines if the instance is greater (after) than another
gte() : bool
  Determines if the instance is greater (after) than or equal to another
hasFormat() : bool
  Checks if the (date)time string is in a given format.
hasFormatWithModifiers() : bool
  Checks if the (date)time string is in a given format.
hasLocalMacro() : bool
  Checks if macro is registered globally or locally.
hasLocalTranslator() : bool
  Return true if the current instance has its own translator.
hasMacro() : bool
  Checks if macro is registered globally.
hasRelativeKeywords() : bool
  Determine if a time string will produce a relative date.
hasTestNow() : bool
  Determine if there is a valid test instance set. A valid test instance is anything that is not null.
instance() : static
  Create a Carbon instance from a DateTime one.
is() : bool
  Returns true if the current date matches the given string.
isAfter() : bool
  Determines if the instance is greater (after) than another
isBefore() : bool
  Determines if the instance is less (before) than another
isBetween() : bool
  Determines if the instance is between two others
isBirthday() : bool
  Check if its the birthday. Compares the date/month values of the two dates.
isCurrentUnit() : bool
  Determines if the instance is in the current unit given.
isDayOfWeek() : bool
  Checks if this day is a specific day of the week.
isEndOfCentury() : bool
  Determines if the instance is end of century (last day by default but interval can be customized).
isEndOfDay() : bool
  Check if the instance is end of day.
isEndOfDecade() : bool
  Determines if the instance is end of decade (last day by default but interval can be customized).
isEndOfHour() : bool
  Determines if the instance is end of hour (last microsecond by default but interval can be customized).
isEndOfMillennium() : bool
  Determines if the instance is end of millennium (last day by default but interval can be customized).
isEndOfMillisecond() : bool
  Determines if the instance is end of millisecond (last microsecond by default but interval can be customized).
isEndOfMinute() : bool
  Determines if the instance is end of minute (last microsecond by default but interval can be customized).
isEndOfMonth() : bool
  Determines if the instance is end of month (last day by default but interval can be customized).
isEndOfQuarter() : bool
  Determines if the instance is end of quarter (last day by default but interval can be customized).
isEndOfSecond() : bool
  Determines if the instance is end of second (last microsecond by default but interval can be customized).
isEndOfTime() : bool
  Returns true if the date was created using CarbonImmutable::endOfTime()
isEndOfUnit() : bool
  Check if the instance is end of a given unit (tolerating a given interval).
isEndOfWeek() : bool
  Determines if the instance is end of week (last day by default but interval can be customized).
isEndOfYear() : bool
  Determines if the instance is end of year (last day by default but interval can be customized).
isFuture() : bool
  Determines if the instance is in the future, ie. greater (after) than now.
isImmutable() : bool
  Returns true if the current class/instance is immutable.
isLastOfMonth() : bool
  Check if today is the last day of the Month
isLeapYear() : bool
  Determines if the instance is a leap year.
isLongIsoYear() : bool
  Determines if the instance is a long year (using ISO 8601 year).
isLongYear() : bool
  Determines if the instance is a long year (using calendar year).
isMidday() : bool
  Check if the instance is midday.
isMidnight() : bool
  Check if the instance is start of day / midnight.
isModifiableUnit() : bool
  Returns true if a property can be changed via setter.
isMutable() : bool
  Returns true if the current class/instance is mutable.
isoFormat() : string
  Format in the current language using ISO replacement patterns.
isoWeek() : int|static
  Get/set the week number using given first day of week and first day of year included in the first week. Or use ISO format if no settings given.
isoWeekday() : static|int
  Get/set the ISO weekday from 1 (Monday) to 7 (Sunday).
isoWeeksInYear() : int
  Get the number of weeks of the current week-year using given first day of week and first day of year included in the first week. Or use ISO format if no settings given.
isoWeekYear() : int|static
  Set/get the week number of year using given first day of week and first day of year included in the first week. Or use ISO format if no settings given.
isPast() : bool
  Determines if the instance is in the past, ie. less (before) than now.
isSameAs() : bool
  Compares the formatted values of the two dates.
isSameMonth() : bool
  Checks if the passed in date is in the same month as the instance´s month.
isSameQuarter() : bool
  Checks if the passed in date is in the same quarter as the instance quarter (and year if needed).
isSameUnit() : bool
  Determines if the instance is in the current unit given.
isStartOfCentury() : bool
  Determines if the instance is start of century (first day by default but interval can be customized).
isStartOfDay() : bool
  Check if the instance is start of day / midnight.
isStartOfDecade() : bool
  Determines if the instance is start of decade (first day by default but interval can be customized).
isStartOfHour() : bool
  Determines if the instance is start of hour (first microsecond by default but interval can be customized).
isStartOfMillennium() : bool
  Determines if the instance is start of millennium (first day by default but interval can be customized).
isStartOfMillisecond() : bool
  Determines if the instance is start of millisecond (first microsecond by default but interval can be customized).
isStartOfMinute() : bool
  Determines if the instance is start of minute (first microsecond by default but interval can be customized).
isStartOfMonth() : bool
  Determines if the instance is start of month (first day by default but interval can be customized).
isStartOfQuarter() : bool
  Determines if the instance is start of quarter (first day by default but interval can be customized).
isStartOfSecond() : bool
  Determines if the instance is start of second (first microsecond by default but interval can be customized).
isStartOfTime() : bool
  Returns true if the date was created using CarbonImmutable::startOfTime()
isStartOfUnit() : bool
  Check if the instance is start of a given unit (tolerating a given interval).
isStartOfWeek() : bool
  Determines if the instance is start of week (first day by default but interval can be customized).
isStartOfYear() : bool
  Determines if the instance is start of year (first day by default but interval can be customized).
isStrictModeEnabled() : bool
  Returns true if the strict mode is globally in use, false else.
isToday() : bool
  Determines if the instance is today.
isTomorrow() : bool
  Determines if the instance is tomorrow.
isWeekday() : bool
  Determines if the instance is a weekday.
isWeekend() : bool
  Determines if the instance is a weekend day.
isYesterday() : bool
  Determines if the instance is yesterday.
jsonSerialize() : mixed
  Prepare the object for JSON serialization.
lastOfMonth() : static
  Modify to the last occurrence of a given day of the week in the current month. If no dayOfWeek is provided, modify to the last day of the current month. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
lastOfQuarter() : static
  Modify to the last occurrence of a given day of the week in the current quarter. If no dayOfWeek is provided, modify to the last day of the current quarter. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
lastOfYear() : static
  Modify to the last occurrence of a given day of the week in the current year. If no dayOfWeek is provided, modify to the last day of the current year. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
lessThan() : bool
  Determines if the instance is less (before) than another
lessThanOrEqualTo() : bool
  Determines if the instance is less (before) or equal to another
locale() : $this|string
  Get/set the locale for the current instance.
localeHasDiffOneDayWords() : bool
  Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
localeHasDiffSyntax() : bool
  Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
localeHasDiffTwoDayWords() : bool
  Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
localeHasPeriodSyntax() : bool
  Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
localeHasShortUnits() : bool
  Returns true if the given locale is internally supported and has short-units support.
lt() : bool
  Determines if the instance is less (before) than another
lte() : bool
  Determines if the instance is less (before) or equal to another
macro() : void
  Register a custom macro.
make() : static|null
  Make a Carbon instance from given variable if possible.
max() : static
  Get the maximum instance between a given instance (default now) and the current instance.
maximum() : static
  Get the maximum instance between a given instance (default now) and the current instance.
meridiem() : string
  Return the meridiem of the current time in the current locale.
midDay() : static
  Modify to midday, default to self::$midDayAt
min() : static
  Get the minimum instance between a given instance (default now) and the current instance.
minimum() : static
  Get the minimum instance between a given instance (default now) and the current instance.
mixin() : void
  Mix another object into the class.
modify() : static
  Calls \DateTime::modify if mutable or \DateTimeImmutable::modify else.
ne() : bool
  Determines if the instance is not equal to another
next() : static
  Modify to the next occurrence of a given modifier such as a day of the week. If no modifier is provided, modify to the next occurrence of the current day of the week. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
nextWeekday() : static
  Go forward to the next weekday.
nextWeekendDay() : static
  Go forward to the next weekend day.
notEqualTo() : bool
  Determines if the instance is not equal to another
now() : static
  Get a Carbon instance for the current date and time.
nowWithSameTz() : static
  Returns a present instance in the same timezone.
nthOfMonth() : mixed
  Modify to the given occurrence of a given day of the week in the current month. If the calculated occurrence is outside the scope of the current month, then return false and no modifications are made.
nthOfQuarter() : mixed
  Modify to the given occurrence of a given day of the week in the current quarter. If the calculated occurrence is outside the scope of the current quarter, then return false and no modifications are made.
nthOfYear() : mixed
  Modify to the given occurrence of a given day of the week in the current year. If the calculated occurrence is outside the scope of the current year, then return false and no modifications are made.
ordinal() : string
  Return a property with its ordinal.
parse() : static
  Create a carbon instance from a string.
parseFromLocale() : static
  Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).
pluralUnit() : string
  Returns standardized plural of a given singular/plural unit name (in English).
previous() : static
  Modify to the previous occurrence of a given modifier such as a day of the week. If no dayOfWeek is provided, modify to the previous occurrence of the current day of the week. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
previousWeekday() : static
  Go backward to the previous weekday.
previousWeekendDay() : static
  Go backward to the previous weekend day.
range() : CarbonPeriod
  Create a iterable CarbonPeriod object from current date to a given end date (and optional interval).
rawAdd() : static
  Call native PHP DateTime/DateTimeImmutable add() method.
rawCreateFromFormat() : static|null
  Create a Carbon instance from a specific format.
rawFormat() : string
rawParse() : static
  Create a carbon instance from a string.
rawSub() : static
  Call native PHP DateTime/DateTimeImmutable sub() method.
resetMacros() : void
  Remove all macros and generic macros.
resetMonthsOverflow() : void
resetToStringFormat() : void
  Reset the format used to the default when type juggling a Carbon instance to a string
resetYearsOverflow() : void
round() : static
  Round the current instance second with given precision if specified.
roundUnit() : static
  Round the current instance at the given unit with given precision if specified and the given function.
roundWeek() : static
  Round the current instance week.
secondsSinceMidnight() : float
  The number of seconds since midnight.
secondsUntilEndOfDay() : float
  The number of seconds until 23:59:59.
serialize() : string
  Return a serialized string of the instance.
serializeUsing() : void
set() : $this
  Set a part of the Carbon object.
setDate() : static
  Set the date with gregorian year, month and day numbers.
setDateFrom() : static
  Set the year, month, and date for this instance to that of the passed instance.
setDateTime() : static
  Set the date and time all together.
setDateTimeFrom() : static
  Set the date and time for this instance to that of the passed instance.
setDaysFromStartOfWeek() : static
  Set the day (keeping the current time) to the start of the week + the number of days passed as the first parameter. First day of week is driven by the locale unless explicitly set with the second parameter.
setFallbackLocale() : void
  Set the fallback locale.
setHumanDiffOptions() : void
setISODate() : static
  Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
setLocale() : void
  Set the current translator locale and indicate if the source locale file exists.
setLocalTranslator() : mixed
  Set the translator for the current instance.
setMidDayAt() : void
setTestNow() : void
  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().
setTestNowAndTimezone() : void
  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().
setTime() : static
  Resets the current time of the DateTime object to a different time.
setTimeFrom() : static
  Set the hour, minute, second and microseconds for this instance to that of the passed instance.
setTimeFromTimeString() : static
  Set the time by time string.
setTimestamp() : static
  Set the instance's timestamp.
setTimezone() : static
  Set the instance's timezone from a string or object.
settings() : $this|static
  Set specific options.
setToStringFormat() : void
setTranslator() : void
  Set the default translator instance to use.
setUnit() : static
  Set specified unit to new given value.
setUnitNoOverflow() : static
  Set any unit to a new value without overflowing current other unit given.
setWeekendDays() : void
shiftTimezone() : static
  Set the instance's timezone from a string or object and add/subtract the offset difference.
shouldOverflowMonths() : bool
  Get the month overflow global behavior (can be overridden in specific instances).
shouldOverflowYears() : bool
  Get the month overflow global behavior (can be overridden in specific instances).
since() : mixed
singularUnit() : string
  Returns standardized singular of a given singular/plural unit name (in English).
sleep() : void
startOf() : static
  Modify to start of current given unit.
startOfCentury() : static
  Resets the date to the first day of the century and the time to 00:00:00
startOfDay() : static
  Resets the time to 00:00:00 start of day
startOfDecade() : static
  Resets the date to the first day of the decade and the time to 00:00:00
startOfHour() : static
  Modify to start of current hour, minutes and seconds become 0
startOfMillennium() : static
  Resets the date to the first day of the millennium and the time to 00:00:00
startOfMillisecond() : static
  Modify to start of current millisecond, microseconds such as 12345 become 123000
startOfMinute() : static
  Modify to start of current minute, seconds become 0
startOfMonth() : static
  Resets the date to the first day of the month and the time to 00:00:00
startOfQuarter() : static
  Resets the date to the first day of the quarter and the time to 00:00:00
startOfSecond() : static
  Modify to start of current second, microseconds become 0
startOfWeek() : static
  Resets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00
startOfYear() : static
  Resets the date to the first day of the year and the time to 00:00:00
sub() : static
  Subtract given units or interval to the current instance.
subRealUnit() : static
subtract() : static
  Subtract given units or interval to the current instance.
subUnit() : static
  Subtract given units to the current instance.
subUnitNoOverflow() : static
  Subtract any unit to a new value without overflowing current other unit given.
subUTCUnit() : static
  Subtract seconds to the instance using timestamp. Positive $value travels into the past while negative $value travels forward.
timespan() : string
  Get the difference in a human-readable format in the current locale from current instance to another instance given (or now if null given).
timestamp() : static
  Set the instance's timestamp.
timezone() : static
to() : string
  Get the difference in a human readable format in the current locale from an other instance given (or now if null given) to current instance.
toArray() : array<string|int, mixed>
  Get default array representation.
toAtomString() : string
  Format the instance as ATOM
toCookieString() : string
  Format the instance as COOKIE
toDate() : DateTime
toDateString() : string
  Format the instance as date
toDateTime() : DateTime
  Return native DateTime PHP object matching the current instance.
toDateTimeImmutable() : DateTimeImmutable
  Return native toDateTimeImmutable PHP object matching the current instance.
toDateTimeLocalString() : string
  Format the instance as date and time T-separated with no timezone
toDateTimeString() : string
  Format the instance as date and time
today() : static
  Create a Carbon instance for today.
toDayDateTimeString() : string
  Format the instance with day, date and time
toFormattedDateString() : string
  Format the instance as a readable date
toFormattedDayDateString() : string
  Format the instance with the day, and a readable date
toImmutable() : CarbonImmutable
  Return a immutable copy of the instance.
toIso8601String() : string
  Format the instance as ISO8601
toIso8601ZuluString() : string
  Convert the instance to UTC and return as Zulu ISO8601
toISOString() : string|null
  Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z, if $keepOffset truthy, offset will be kept: 1977-04-22T01:00:00-05:00).
toJSON() : string|null
  Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z) with UTC timezone.
tomorrow() : static
  Create a Carbon instance for tomorrow.
toMutable() : Carbon
  Return a mutable copy of the instance.
toNow() : string
  Get the difference in a human readable format in the current locale from an other instance given to now
toObject() : object
  Get default object representation.
toPeriod() : CarbonPeriod
  Create a iterable CarbonPeriod object from current date to a given end date (and optional interval).
toRfc1036String() : string
  Format the instance as RFC1036
toRfc1123String() : string
  Format the instance as RFC1123
toRfc2822String() : string
  Format the instance as RFC2822
toRfc3339String() : string
  Format the instance as RFC3339.
toRfc7231String() : string
  Format the instance as RFC7231
toRfc822String() : string
  Format the instance as RFC822
toRfc850String() : string
  Format the instance as RFC850
toRssString() : string
  Format the instance as RSS
toString() : string
  Returns english human-readable complete date string.
toTimeString() : string
  Format the instance as time
toW3cString() : string
  Format the instance as W3C
translate() : string
  Translate using translation string or callback available.
translatedFormat() : string
  Format as ->format() do (using date replacements patterns from https://php.net/manual/en/function.date.php) but translate words whenever possible (months, day names, etc.) using the current locale.
translateNumber() : string
  Returns the alternative number for a given integer if available in the current locale.
translateTimeString() : string
  Translate a time string from a locale to an other.
translateTimeStringTo() : string
  Translate a time string from the current locale (`$date->locale()`) to an other.
translateWith() : string
  Translate using translation string or callback available.
tz() : static|string
  Set the timezone or returns the timezone name if no arguments passed.
unix() : int
until() : string
useMonthsOverflow() : void
useStrictMode() : void
useYearsOverflow() : void
utc() : static
  Set the instance's timezone to UTC.
utcOffset() : static|int
  Returns the minutes offset to UTC if no arguments passed, else set the timezone with given minutes shift passed.
valueOf() : float
  Returns the milliseconds timestamps used amongst other by Date javascript objects.
week() : int|static
  Get/set the week number using given first day of week and first day of year included in the first week. Or use US format if no settings given (Sunday / Jan 6).
weekday() : static|int
  Get/set the weekday from 0 (Sunday) to 6 (Saturday).
weeksInYear() : int
  Get the number of weeks of the current week-year using given first day of week and first day of year included in the first week. Or use US format if no settings given (Sunday / Jan 6).
weekYear() : int|static
  Set/get the week number of year using given first day of week and first day of year included in the first week. Or use US format if no settings given (Sunday / Jan 6).
withTestNow() : T
  Temporarily sets a static date to be used within the callback.
yesterday() : static
  Create a Carbon instance for yesterday.

### Constants

#### APRIL

CarbonInterface.php : 905
`public mixed APRIL = 4`

#### AUGUST

CarbonInterface.php : 909
`public mixed AUGUST = 8`

#### CEIL

CarbonInterface.php : 866
`public mixed CEIL = 0200`

#### DAYS_PER_WEEK

CarbonInterface.php : 927
`public mixed DAYS_PER_WEEK = 7`

#### DAYS_PER_YEAR

CarbonInterface.php : 926
`public mixed DAYS_PER_YEAR = 365`

#### DECEMBER

CarbonInterface.php : 913
`public mixed DECEMBER = 12`

#### DEFAULT_LOCALE

CarbonInterface.php : 973

Default locale (language and region).

`public string DEFAULT_LOCALE = 'en'`

#### DEFAULT_TO_STRING_FORMAT

CarbonInterface.php : 952

Default format to use for __toString method when type juggling occurs.

`public string DEFAULT_TO_STRING_FORMAT = 'Y-m-d H:i:s'`

#### DIFF_ABSOLUTE

CarbonInterface.php : 871

Diff syntax options.

`public mixed DIFF_ABSOLUTE = 1`

#### DIFF_RELATIVE_AUTO

CarbonInterface.php : 872
`public mixed DIFF_RELATIVE_AUTO = 0`

#### DIFF_RELATIVE_TO_NOW

CarbonInterface.php : 873
`public mixed DIFF_RELATIVE_TO_NOW = 2`

#### DIFF_RELATIVE_TO_OTHER

CarbonInterface.php : 874
`public mixed DIFF_RELATIVE_TO_OTHER = 3`

#### FEBRUARY

CarbonInterface.php : 903
`public mixed FEBRUARY = 2`

#### FLOOR

CarbonInterface.php : 865
`public mixed FLOOR = 0100`

#### FRIDAY

CarbonInterface.php : 894
`public mixed FRIDAY = 5`

#### HOURS_PER_DAY

CarbonInterface.php : 928
`public mixed HOURS_PER_DAY = 24`

#### ISO_FORMAT_REGEXP

CarbonInterface.php : 966

Pattern detection for ->isoFormat and ::createFromIsoFormat.

`public string ISO_FORMAT_REGEXP = '(O[YMDHhms]|[Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY?|g{1,5}|G{1,5}|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?)'`

#### JANUARY

CarbonInterface.php : 902

The month constants.

`public mixed JANUARY = 1`

These aren't used by Carbon itself but exist for convenience sake alone.

#### JULY

CarbonInterface.php : 908
`public mixed JULY = 7`

#### JUNE

CarbonInterface.php : 907
`public mixed JUNE = 6`

#### JUST_NOW

CarbonInterface.php : 860
`public mixed JUST_NOW = 02`

#### MARCH

CarbonInterface.php : 904
`public mixed MARCH = 3`

#### MAY

CarbonInterface.php : 906
`public mixed MAY = 5`

#### MICROSECONDS_PER_MILLISECOND

CarbonInterface.php : 932
`public mixed MICROSECONDS_PER_MILLISECOND = 1000`

#### MICROSECONDS_PER_SECOND

CarbonInterface.php : 933
`public mixed MICROSECONDS_PER_SECOND = 1000000`

#### MILLISECONDS_PER_SECOND

CarbonInterface.php : 931
`public mixed MILLISECONDS_PER_SECOND = 1000`

#### MINUTES_PER_HOUR

CarbonInterface.php : 929
`public mixed MINUTES_PER_HOUR = 60`

#### MOCK_DATETIME_FORMAT

CarbonInterface.php : 959

Format for converting mocked time, includes microseconds.

`public string MOCK_DATETIME_FORMAT = 'Y-m-d H:i:s.u'`

#### MONDAY

CarbonInterface.php : 890
`public mixed MONDAY = 1`

#### MONTHS_PER_QUARTER

CarbonInterface.php : 922
`public mixed MONTHS_PER_QUARTER = 3`

#### MONTHS_PER_YEAR

CarbonInterface.php : 921
`public mixed MONTHS_PER_YEAR = 12`

#### NO_ZERO_DIFF

CarbonInterface.php : 859

Diff wording options(expressed in octal).

`public mixed NO_ZERO_DIFF = 01`

#### NOVEMBER

CarbonInterface.php : 912
`public mixed NOVEMBER = 11`

#### OCTOBER

CarbonInterface.php : 911
`public mixed OCTOBER = 10`

#### ONE_DAY_WORDS

CarbonInterface.php : 861
`public mixed ONE_DAY_WORDS = 04`

#### QUARTERS_PER_YEAR

CarbonInterface.php : 923
`public mixed QUARTERS_PER_YEAR = 4`

#### RFC7231_FORMAT

CarbonInterface.php : 945

RFC7231 DateTime format.

`public string RFC7231_FORMAT = 'D, d M Y H:i:s \\G\\M\\T'`

#### ROUND

CarbonInterface.php : 864
`public mixed ROUND = 040`

#### SATURDAY

CarbonInterface.php : 895
`public mixed SATURDAY = 6`

#### SECONDS_PER_MINUTE

CarbonInterface.php : 930
`public mixed SECONDS_PER_MINUTE = 60`

#### SEPTEMBER

CarbonInterface.php : 910
`public mixed SEPTEMBER = 9`

#### SEQUENTIAL_PARTS_ONLY

CarbonInterface.php : 863
`public mixed SEQUENTIAL_PARTS_ONLY = 020`

#### SUNDAY

CarbonInterface.php : 889

The day constants.

`public mixed SUNDAY = 0`

#### THURSDAY

CarbonInterface.php : 893
`public mixed THURSDAY = 4`

#### TRANSLATE_ALL

CarbonInterface.php : 884
`public mixed TRANSLATE_ALL = self::TRANSLATE_MONTHS | self::TRANSLATE_DAYS | self::TRANSLATE_UNITS | self::TRANSLATE_MERIDIEM | self::TRANSLATE_DIFF`

#### TRANSLATE_DAYS

CarbonInterface.php : 880
`public mixed TRANSLATE_DAYS = 2`

#### TRANSLATE_DIFF

CarbonInterface.php : 883
`public mixed TRANSLATE_DIFF = 0x10`

#### TRANSLATE_MERIDIEM

CarbonInterface.php : 882
`public mixed TRANSLATE_MERIDIEM = 8`

#### TRANSLATE_MONTHS

CarbonInterface.php : 879

Translate string options.

`public mixed TRANSLATE_MONTHS = 1`

#### TRANSLATE_UNITS

CarbonInterface.php : 881
`public mixed TRANSLATE_UNITS = 4`

#### TUESDAY

CarbonInterface.php : 891
`public mixed TUESDAY = 2`

#### TWO_DAY_WORDS

CarbonInterface.php : 862
`public mixed TWO_DAY_WORDS = 010`

#### WEDNESDAY

CarbonInterface.php : 892
`public mixed WEDNESDAY = 3`

#### WEEK_DAY_AUTO

CarbonInterface.php : 938

Special settings to get the start of week from current locale culture.

`public mixed WEEK_DAY_AUTO = 'auto'`

#### WEEKS_PER_MONTH

CarbonInterface.php : 925
`public mixed WEEKS_PER_MONTH = 4`

#### WEEKS_PER_YEAR

CarbonInterface.php : 924
`public mixed WEEKS_PER_YEAR = 52`

#### YEARS_PER_CENTURY

CarbonInterface.php : 919
`public mixed YEARS_PER_CENTURY = 100`

#### YEARS_PER_DECADE

CarbonInterface.php : 920
`public mixed YEARS_PER_DECADE = 10`

#### YEARS_PER_MILLENNIUM

CarbonInterface.php : 918

Number of X in Y.

`public mixed YEARS_PER_MILLENNIUM = 1000`

### Methods

#### __call()

CarbonInterface.php : 985

Dynamically handle calls to the class.

`public __call(string $method, array<string|int, mixed> $parameters) : mixed`

##### Parameters

$method : string

  magic method name called

$parameters : array<string|int, mixed>

  parameters list

##### Tags

throws
  UnknownMethodException|BadMethodCallException|ReflectionException|Throwable

#### __callStatic()

CarbonInterface.php : 995

Dynamically handle calls to the class.

`public static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed`

##### Parameters

$method : string

  magic method name called

$parameters : array<string|int, mixed>

  parameters list

##### Tags

throws
  BadMethodCallException

#### __clone()

CarbonInterface.php : 1000

Update constructedObjectId on cloned.

`public __clone() : void`

#### __construct()

CarbonInterface.php : 1010

Create a new Carbon instance.

`public __construct([DateTimeInterface|WeekDay|Month|string|int|float|null $time = null ][, DateTimeZone|string|int|null $timezone = null ]) : mixed`

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

##### Parameters

$time : DateTimeInterface|WeekDay|Month|string|int|float|null = null
$timezone : DateTimeZone|string|int|null = null

##### Tags

throws
  InvalidFormatException

#### __debugInfo()

CarbonInterface.php : 1015

Show truthy properties on var_dump().

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

##### Return values

array<string|int, mixed>

#### __get()

CarbonInterface.php : 1024

Get a part of the Carbon object.

`public __get(string $name) : string|int|bool|DateTimeZone|null`

##### Parameters

$name : string

##### Tags

throws
  UnknownGetterException

##### Return values

string|int|bool|DateTimeZone|null

#### __isset()

CarbonInterface.php : 1033

Check if an attribute exists on the object

`public __isset(string $name) : bool`

##### Parameters

$name : string

##### Return values

bool

#### __set()

CarbonInterface.php : 1045

Set a part of the Carbon object

`public __set(string $name, string|int|DateTimeZone $value) : void`

##### Parameters

$name : string
$value : string|int|DateTimeZone

##### Tags

throws
  UnknownSetterException|ReflectionException

#### __set_state()

CarbonInterface.php : 1054

The __set_state handler.

`public static __set_state(string|array<string|int, mixed> $dump) : static`

##### Parameters

$dump : string|array<string|int, mixed>

##### Return values

static

#### __sleep()

CarbonInterface.php : 1064

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

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

Only used by PHP < 7.4.

##### Return values

array<string|int, mixed>

#### __toString()

CarbonInterface.php : 1074

Format the instance as a string using the set format

`public __toString() : mixed`

##### Tags

example

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

#### add()

CarbonInterface.php : 1089

Add given units or interval to the current instance.

`public add(Unit|string|DateInterval|Closure|CarbonConverterInterface $unit[, int|float $value = 1 ][, bool|null $overflow = null ]) : static`

##### Parameters

$unit : Unit|string|DateInterval|Closure|CarbonConverterInterface
$value : int|float = 1
$overflow : bool|null = null

##### Tags

example

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

example

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

example

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

##### Return values

static

#### addRealUnit()

CarbonInterface.php : 1103
`public addRealUnit(string $unit[, int|float|null $value = 1 ]) : static`

##### Parameters

$unit : string
$value : int|float|null = 1

##### Tags

deprecated

  Prefer to use add addUTCUnit() which more accurately defines what it's doing.

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

##### Return values

static

#### addUnit()

CarbonInterface.php : 1119

Add given units to the current instance.

`public addUnit(Unit|string $unit[, mixed $value = 1 ][, bool|null $overflow = null ]) : static`

##### Parameters

$unit : Unit|string
$value : mixed = 1
$overflow : bool|null = null

##### Return values

static

#### addUnitNoOverflow()

CarbonInterface.php : 1128

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

`public addUnitNoOverflow(string $valueUnit, int $value, string $overflowUnit) : static`

##### Parameters

$valueUnit : string

  unit name to modify

$value : int

  amount to add to the input unit

$overflowUnit : string

  unit name to not overflow

##### Return values

static

#### addUTCUnit()

CarbonInterface.php : 1114

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

`public addUTCUnit(string $unit[, int|float|null $value = 1 ]) : static`

##### Parameters

$unit : string
$value : int|float|null = 1

##### Return values

static

#### ago()

CarbonInterface.php : 1158

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

`public ago([int|array<string|int, mixed> $syntax = null ][, bool $short = false ][, int $parts = 1 ][, int $options = null ]) : string`

##### Parameters

$syntax : int|array<string|int, mixed> = null

  if array passed, parameters will be extracted from it, the array may contains:

  - 'syntax' entry (see below)
  - 'short' entry (see below)
  - 'parts' entry (see below)
  - 'options' entry (see below)
  - 'join' entry determines how to join multiple parts of the string `- if $join is a string, it's used as a joiner glue` - if $join is a callable/closure, it get the list of string and should return a string `- if $join is an array, the first item will be the default glue, and the second item` will be used instead of the glue for the last item `- if $join is true, it will be guessed from the locale ('list' translation file entry)` - if $join is missing, a space will be used as glue if int passed, it add modifiers: Possible values:
  - CarbonInterface::DIFF_ABSOLUTE no modifiers
  - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
  - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier Default value: CarbonInterface::DIFF_ABSOLUTE
$short : bool = false

  displays short format of time units

$parts : int = 1

  maximum number of parts to display (default value: 1: single part)

$options : int = null

  human diff options

##### Return values

string

#### average()

CarbonInterface.php : 1168

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

`public average([Carbon|DateTimeInterface|null $date = null ]) : static`

##### Parameters

$date : Carbon|DateTimeInterface|null = null

##### Return values

static

#### avoidMutation()

CarbonInterface.php : 1178

Clone the current instance if it's mutable.

`public avoidMutation() : static`

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.

##### Return values

static

#### between()

CarbonInterface.php : 1197

Determines if the instance is between two others.

`public between(DateTimeInterface|string $date1, DateTimeInterface|string $date2[, bool $equal = true ]) : bool`

The third argument allow you to specify if bounds are included or not (true by default) but for when you including/excluding bounds may produce different results in your application, we recommend to use the explicit methods ->betweenIncluded() or ->betweenExcluded() instead.

##### Parameters

$date1 : DateTimeInterface|string
$date2 : DateTimeInterface|string
$equal : bool = true

  Indicates if an equal to comparison should be done

##### Tags

example

      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

##### Return values

bool

#### betweenExcluded()

CarbonInterface.php : 1209

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

`public betweenExcluded(DateTimeInterface|string $date1, DateTimeInterface|string $date2) : bool`

##### Parameters

$date1 : DateTimeInterface|string
$date2 : DateTimeInterface|string

##### Tags

example

      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

##### Return values

bool

#### betweenIncluded()

CarbonInterface.php : 1221

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

`public betweenIncluded(DateTimeInterface|string $date1, DateTimeInterface|string $date2) : bool`

##### Parameters

$date1 : DateTimeInterface|string
$date2 : DateTimeInterface|string

##### Tags

example

      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

##### Return values

bool

#### calendar()

CarbonInterface.php : 1234

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

`public calendar([Carbon|DateTimeInterface|string|null $referenceTime = null ][, array<string|int, mixed> $formats = [] ]) : string`

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

##### Parameters

$referenceTime : Carbon|DateTimeInterface|string|null = null
$formats : array<string|int, mixed> = []

##### Return values

string

#### canBeCreatedFromFormat()

CarbonInterface.php : 1246

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

`public static canBeCreatedFromFormat(string|null $date, string $format) : bool`

##### Parameters

$date : string|null
$format : string

##### Tags

example

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

##### Return values

bool

#### carbonize()

CarbonInterface.php : 1256

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

`public carbonize([Carbon|CarbonPeriod|CarbonInterval|DateInterval|DatePeriod|DateTimeInterface|string|null $date = null ]) : static`

##### Parameters

$date : Carbon|CarbonPeriod|CarbonInterval|DateInterval|DatePeriod|DateTimeInterface|string|null = null

##### Return values

static

#### cast()

CarbonInterface.php : 1267

Cast the current instance into the given class.

`public cast(T> $className) : T`

##### Parameters

$className : T>

  The $className::instance() method will be called to cast the current object.

##### Tags

template

  T

##### Return values

T

#### ceil()

CarbonInterface.php : 1272

Ceil the current instance second with given precision if specified.

`public ceil([DateInterval|string|int|float $precision = 1 ]) : static`

##### Parameters

$precision : DateInterval|string|int|float = 1

##### Return values

static

#### ceilUnit()

CarbonInterface.php : 1277

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

`public ceilUnit(string $unit[, DateInterval|string|int|float $precision = 1 ]) : static`

##### Parameters

$unit : string
$precision : DateInterval|string|int|float = 1

##### Return values

static

#### ceilWeek()

CarbonInterface.php : 1284

Ceil the current instance week.

`public ceilWeek([WeekDay|int|null $weekStartsAt = null ]) : static`

##### Parameters

$weekStartsAt : WeekDay|int|null = null

  optional start allow you to specify the day of week to use to start the week

##### Return values

static

#### change()

CarbonInterface.php : 1300

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

`public change(string $modifier) : static`

##### Parameters

$modifier : string

##### Tags

example

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

link
  https://php.net/manual/en/datetime.modify.php

##### Return values

static

#### cleanupDumpProperties()

CarbonInterface.php : 1309

Cleanup properties attached to the public scope of DateTime when a dump of the date is requested.

`public cleanupDumpProperties() : mixed`

foreach ($date as $_) } serializer($date) var_export($date) get_object_vars($date)

#### clone()

CarbonInterface.php : 1318
`public clone() : static`

##### Tags

alias

  copy

  Get a copy of the instance.

##### Return values

static

#### closest()

CarbonInterface.php : 1328

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

`public closest(Carbon|DateTimeInterface|mixed $date1, Carbon|DateTimeInterface|mixed $date2) : static`

##### Parameters

$date1 : Carbon|DateTimeInterface|mixed
$date2 : Carbon|DateTimeInterface|mixed

##### Return values

static

#### copy()

CarbonInterface.php : 1335

Get a copy of the instance.

`public copy() : static`

##### Return values

static

#### create()

CarbonInterface.php : 1361

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

`public static create([DateTimeInterface|string|int|null $year = 0 ][, int|null $month = 1 ][, int|null $day = 1 ][, int|null $hour = 0 ][, int|null $minute = 0 ][, int|null $second = 0 ][, DateTimeZone|string|int|null $timezone = null ]) : static|null`

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.

##### Parameters

$year : DateTimeInterface|string|int|null = 0
$month : int|null = 1
$day : int|null = 1
$hour : int|null = 0
$minute : int|null = 0
$second : int|null = 0
$timezone : DateTimeZone|string|int|null = null

##### Tags

throws
  InvalidFormatException

##### Return values

static|null

#### createFromDate()

CarbonInterface.php : 1375

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

`public static createFromDate([int|null $year = null ][, int|null $month = null ][, int|null $day = null ][, DateTimeZone|string|int|null $timezone = null ]) : static`

##### Parameters

$year : int|null = null
$month : int|null = null
$day : int|null = null
$timezone : DateTimeZone|string|int|null = null

##### Tags

throws
  InvalidFormatException

##### Return values

static

#### createFromFormat()

CarbonInterface.php : 1388

Create a Carbon instance from a specific format.

`public static createFromFormat(string $format, string $time[, DateTimeZone|string|int|null $timezone = null ]) : static|null`

##### Parameters

$format : string

  Datetime format

$time : string
$timezone : DateTimeZone|string|int|null = null

##### Tags

throws
  InvalidFormatException

##### Return values

static|null

#### createFromIsoFormat()

CarbonInterface.php : 1404

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

`public static createFromIsoFormat(string $format, string $time[, DateTimeZone|string|int|null $timezone = null ][, string|null $locale = 'en' ][, TranslatorInterface|null $translator = null ]) : static|null`

##### Parameters

$format : string

  Datetime format

$time : string
$timezone : DateTimeZone|string|int|null = null

  optional timezone

$locale : string|null = 'en'

  locale to be used for LTS, LT, LL, LLL, etc. macro-formats (en by fault, unneeded if no such macro-format in use)

$translator : TranslatorInterface|null = null

  optional custom translator to use for macro-formats

##### Tags

throws
  InvalidFormatException

##### Return values

static|null

#### createFromLocaleFormat()

CarbonInterface.php : 1418

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

`public static createFromLocaleFormat(string $format, string $locale, string $time[, DateTimeZone|string|int|null $timezone = null ]) : static|null`

##### Parameters

$format : string

  Datetime format

$locale : string
$time : string
$timezone : DateTimeZone|string|int|null = null

##### Tags

throws
  InvalidFormatException

##### Return values

static|null

#### createFromLocaleIsoFormat()

CarbonInterface.php : 1432

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

`public static createFromLocaleIsoFormat(string $format, string $locale, string $time[, DateTimeZone|string|int|null $timezone = null ]) : static|null`

##### Parameters

$format : string

  Datetime ISO format

$locale : string
$time : string
$timezone : DateTimeZone|string|int|null = null

##### Tags

throws
  InvalidFormatException

##### Return values

static|null

#### createFromTime()

CarbonInterface.php : 1446

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

`public static createFromTime([int|null $hour = 0 ][, int|null $minute = 0 ][, int|null $second = 0 ][, DateTimeZone|string|int|null $timezone = null ]) : static`

##### Parameters

$hour : int|null = 0
$minute : int|null = 0
$second : int|null = 0
$timezone : DateTimeZone|string|int|null = null

##### Tags

throws
  InvalidFormatException

##### Return values

static

#### createFromTimestamp()

CarbonInterface.php : 1460

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

`public static createFromTimestamp(string|int|float $timestamp[, DateTimeZone|string|int|null $timezone = null ]) : static`

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

##### Parameters

$timestamp : string|int|float
$timezone : DateTimeZone|string|int|null = null

##### Return values

static

#### createFromTimestampMs()

CarbonInterface.php : 1467

Create a Carbon instance from a timestamp in milliseconds.

`public static createFromTimestampMs(string|int|float $timestamp[, DateTimeZone|string|int|null $timezone = null ]) : static`

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

##### Parameters

$timestamp : string|int|float
$timezone : DateTimeZone|string|int|null = null

##### Return values

static

#### createFromTimestampMsUTC()

CarbonInterface.php : 1478

Create a Carbon instance from a timestamp in milliseconds.

`public static createFromTimestampMsUTC(float|int|string $timestamp) : static`

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

##### Parameters

$timestamp : float|int|string

##### Return values

static

#### createFromTimestampUTC()

CarbonInterface.php : 1485

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

`public static createFromTimestampUTC(string|int|float $timestamp) : static`

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

##### Parameters

$timestamp : string|int|float

##### Return values

static

#### createFromTimeString()

CarbonInterface.php : 1453

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

`public static createFromTimeString(string $time[, DateTimeZone|string|int|null $timezone = null ]) : static`

##### Parameters

$time : string
$timezone : DateTimeZone|string|int|null = null

##### Tags

throws
  InvalidFormatException

##### Return values

static

#### createMidnightDate()

CarbonInterface.php : 1499

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

`public static createMidnightDate([int|null $year = null ][, int|null $month = null ][, int|null $day = null ][, DateTimeZone|string|int|null $timezone = null ]) : static`

##### Parameters

$year : int|null = null
$month : int|null = null
$day : int|null = null
$timezone : DateTimeZone|string|int|null = null

##### Tags

throws
  InvalidFormatException

##### Return values

static

#### createSafe()

CarbonInterface.php : 1528

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

`public static createSafe([int|null $year = null ][, int|null $month = null ][, int|null $day = null ][, int|null $hour = null ][, int|null $minute = null ][, int|null $second = null ][, DateTimeZone|string|int|null $timezone = null ]) : static|null`

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.

##### Parameters

$year : int|null = null
$month : int|null = null
$day : int|null = null
$hour : int|null = null
$minute : int|null = null
$second : int|null = null
$timezone : DateTimeZone|string|int|null = null

##### Tags

throws
  InvalidDateException

##### Return values

static|null

#### createStrict()

CarbonInterface.php : 1547

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

`public static createStrict([int|null $year = 0 ][, int|null $month = 1 ][, int|null $day = 1 ][, int|null $hour = 0 ][, int|null $minute = 0 ][, int|null $second = 0 ][, DateTimeZone|string|int|null $timezone = null ]) : static`

##### Parameters

$year : int|null = 0
$month : int|null = 1
$day : int|null = 1
$hour : int|null = 0
$minute : int|null = 0
$second : int|null = 0
$timezone : DateTimeZone|string|int|null = null

##### Tags

see
  create()
throws
  InvalidFormatException

##### Return values

static

#### dayOfYear()

CarbonInterface.php : 1562

Get/set the day of year.

`public dayOfYear([int|null $value = null ]) : static|int`

##### Parameters

$value : int|null = null

  new value for day of year if using as setter.

##### Tags

template

  T of int|null

psalm-param

  T $value

psalm-return

  (T is int ? static : int)

##### Return values

static|int

#### diffAsCarbonInterval()

CarbonInterface.php : 1574

Get the difference as a CarbonInterval instance.

`public diffAsCarbonInterval([CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ][, array<string|int, mixed> $skip = [] ]) : CarbonInterval`

Return relative interval (negative if $absolute flag is not set to true and the given date is before current one).

##### Parameters

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

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

##### Return values

CarbonInterval

#### diffAsDateInterval()

CarbonInterface.php : 1586

Get the difference as a DateInterval instance.

`public diffAsDateInterval([CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ]) : DateInterval`

Return relative interval (negative if $absolute flag is not set to true and the given date is before current one).

##### Parameters

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

##### Return values

DateInterval

#### diffFiltered()

CarbonInterface.php : 1598

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

`public diffFiltered(CarbonInterval $ci, Closure $callback[, CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ]) : int`

##### Parameters

$ci : CarbonInterval

  An interval to traverse by

$callback : Closure
$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

##### Return values

int

#### diffForHumans()

CarbonInterface.php : 1650

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

`public diffForHumans([Carbon|DateTimeInterface|string|array<string|int, mixed>|null $other = null ][, int|array<string|int, mixed> $syntax = null ][, bool $short = false ][, int $parts = 1 ][, int $options = null ]) : string`

##### Parameters

$other : Carbon|DateTimeInterface|string|array<string|int, mixed>|null = null

  if array passed, will be used as parameters array, see $syntax below; if null passed, now will be used as comparison reference; if any other type, it will be converted to date and used as reference.

$syntax : int|array<string|int, mixed> = null

  if array passed, parameters will be extracted from it, the array may contains: ⦿ 'syntax' entry (see below) ⦿ 'short' entry (see below) ⦿ 'parts' entry (see below) ⦿ 'options' entry (see below) ⦿ 'skip' entry, list of units to skip (array of strings or a single string, `it can be the unit name (singular or plural) or its shortcut` (y, m, w, d, h, min, s, ms, µs). ⦿ 'aUnit' entry, prefer "an hour" over "1 hour" if true ⦿ 'altNumbers' entry, use alternative numbers if available `(from the current language if true is passed, from the given language(s)` if array or string is passed) ⦿ 'join' entry determines how to join multiple parts of the string `- if $join is a string, it's used as a joiner glue` - if $join is a callable/closure, it get the list of string and should return a string `- if $join is an array, the first item will be the default glue, and the second item` will be used instead of the glue for the last item `- if $join is true, it will be guessed from the locale ('list' translation file entry)` - if $join is missing, a space will be used as glue ⦿ 'other' entry (see above) ⦿ 'minimumUnit' entry determines the smallest unit of time to display can be long or ` short form of the units, e.g. 'hour' or 'h' (default value: s) ⦿ 'locale' language in which the diff should be output (has no effect if 'translator' key is set) ⦿ 'translator' a custom translator to use to translator the output. if int passed, it adds modifiers: Possible values:

  - CarbonInterface::DIFF_ABSOLUTE no modifiers
  - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
  - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier Default value: CarbonInterface::DIFF_ABSOLUTE
$short : bool = false

  displays short format of time units

$parts : int = 1

  maximum number of parts to display (default value: 1: single unit)

$options : int = null

  human diff options

##### Tags

example

      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";

##### Return values

string

#### diffInDays()

CarbonInterface.php : 1661

Get the difference in days.

`public diffInDays([CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ][, bool $utc = false ]) : float`

##### Parameters

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

$utc : bool = false

  Always convert dates to UTC before comparing (if not set, it will do it only if timezones are different)

##### Return values

float

#### diffInDaysFiltered()

CarbonInterface.php : 1672

Get the difference in days using a filter closure.

`public diffInDaysFiltered(Closure $callback[, CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ]) : int`

##### Parameters

$callback : Closure
$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

##### Return values

int

#### diffInHours()

CarbonInterface.php : 1682

Get the difference in hours.

`public diffInHours([CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ]) : float`

##### Parameters

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

##### Return values

float

#### diffInHoursFiltered()

CarbonInterface.php : 1693

Get the difference in hours using a filter closure.

`public diffInHoursFiltered(Closure $callback[, CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ]) : int`

##### Parameters

$callback : Closure
$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

##### Return values

int

#### diffInMicroseconds()

CarbonInterface.php : 1703

Get the difference in microseconds.

`public diffInMicroseconds([CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ]) : float`

##### Parameters

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

##### Return values

float

#### diffInMilliseconds()

CarbonInterface.php : 1713

Get the difference in milliseconds.

`public diffInMilliseconds([CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ]) : float`

##### Parameters

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

##### Return values

float

#### diffInMinutes()

CarbonInterface.php : 1723

Get the difference in minutes.

`public diffInMinutes([CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ]) : float`

##### Parameters

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

##### Return values

float

#### diffInMonths()

CarbonInterface.php : 1734

Get the difference in months.

`public diffInMonths([CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ][, bool $utc = false ]) : float`

##### Parameters

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

$utc : bool = false

  Always convert dates to UTC before comparing (if not set, it will do it only if timezones are different)

##### Return values

float

#### diffInQuarters()

CarbonInterface.php : 1745

Get the difference in quarters.

`public diffInQuarters([CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ][, bool $utc = false ]) : float`

##### Parameters

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

$utc : bool = false

  Always convert dates to UTC before comparing (if not set, it will do it only if timezones are different)

##### Return values

float

#### diffInSeconds()

CarbonInterface.php : 1755

Get the difference in seconds.

`public diffInSeconds([CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ]) : float`

##### Parameters

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

##### Return values

float

#### diffInUnit()

CarbonInterface.php : 1767
`public diffInUnit(Unit|string $unit[, CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ][, bool $utc = false ]) : float`

##### Parameters

$unit : Unit|string

  microsecond, millisecond, second, minute, hour, day, week, month, quarter, year, century, millennium

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

$utc : bool = false

  Always convert dates to UTC before comparing (if not set, it will do it only if timezones are different)

##### Return values

float

#### diffInWeekdays()

CarbonInterface.php : 1777

Get the difference in weekdays.

`public diffInWeekdays([CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ]) : int`

##### Parameters

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

##### Return values

int

#### diffInWeekendDays()

CarbonInterface.php : 1787

Get the difference in weekend days using a filter.

`public diffInWeekendDays([CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ]) : int`

##### Parameters

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

##### Return values

int

#### diffInWeeks()

CarbonInterface.php : 1798

Get the difference in weeks.

`public diffInWeeks([CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ][, bool $utc = false ]) : float`

##### Parameters

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

$utc : bool = false

  Always convert dates to UTC before comparing (if not set, it will do it only if timezones are different)

##### Return values

float

#### diffInYears()

CarbonInterface.php : 1809

Get the difference in years

`public diffInYears([CarbonInterface|DateTimeInterface|string|null $date = null ][, bool $absolute = false ][, bool $utc = false ]) : float`

##### Parameters

$date : CarbonInterface|DateTimeInterface|string|null = null
$absolute : bool = false

  Get the absolute of the difference

$utc : bool = false

  Always convert dates to UTC before comparing (if not set, it will do it only if timezones are different)

##### Return values

float

#### disableHumanDiffOption()

CarbonInterface.php : 1816
`public static disableHumanDiffOption(int $humanDiffOption) : void`

##### Parameters

$humanDiffOption : int

##### Tags

deprecated

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

see
  settings

#### enableHumanDiffOption()

CarbonInterface.php : 1823
`public static enableHumanDiffOption(int $humanDiffOption) : void`

##### Parameters

$humanDiffOption : int

##### Tags

deprecated

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

see
  settings

#### endOf()

CarbonInterface.php : 1835

Modify to end of current given unit.

`public endOf(Unit|string $unit, mixed ...$params) : static`

##### Parameters

$unit : Unit|string
$params : mixed

##### Tags

example

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

##### Return values

static

#### endOfCentury()

CarbonInterface.php : 1847

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

`public endOfCentury() : static`

##### Tags

example

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

##### Return values

static

#### endOfDay()

CarbonInterface.php : 1859

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

`public endOfDay() : static`

##### Tags

example

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

##### Return values

static

#### endOfDecade()

CarbonInterface.php : 1871

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

`public endOfDecade() : static`

##### Tags

example

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

##### Return values

static

#### endOfHour()

CarbonInterface.php : 1881

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

`public endOfHour() : static`

##### Tags

example

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

##### Return values

static

#### endOfMillennium()

CarbonInterface.php : 1893

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

`public endOfMillennium() : static`

##### Tags

example

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

##### Return values

static

#### endOfMillisecond()

CarbonInterface.php : 1905

Modify to end of current millisecond, microseconds such as 12345 become 123999

`public endOfMillisecond() : static`

##### Tags

example

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

##### Return values

static

#### endOfMinute()

CarbonInterface.php : 1915

Modify to end of current minute, seconds become 59

`public endOfMinute() : static`

##### Tags

example

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

##### Return values

static

#### endOfMonth()

CarbonInterface.php : 1927

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

`public endOfMonth() : static`

##### Tags

example

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

##### Return values

static

#### endOfQuarter()

CarbonInterface.php : 1939

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

`public endOfQuarter() : static`

##### Tags

example

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

##### Return values

static

#### endOfSecond()

CarbonInterface.php : 1951

Modify to end of current second, microseconds become 999999

`public endOfSecond() : static`

##### Tags

example

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

##### Return values

static

#### endOfWeek()

CarbonInterface.php : 1967

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

`public endOfWeek([WeekDay|int|null $weekEndsAt = null ]) : static`

##### Parameters

$weekEndsAt : WeekDay|int|null = null

  optional end allow you to specify the day of week to use to end the week

##### Tags

example

      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";

##### Return values

static

#### endOfYear()

CarbonInterface.php : 1979

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

`public endOfYear() : static`

##### Tags

example

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

##### Return values

static

#### eq()

CarbonInterface.php : 1993

Determines if the instance is equal to another

`public eq(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      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

see
  equalTo()

##### Return values

bool

#### equalTo()

CarbonInterface.php : 2005

Determines if the instance is equal to another

`public equalTo(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      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

##### Return values

bool

#### executeWithLocale()

CarbonInterface.php : 2016

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

`public static executeWithLocale(string $locale, callable $func) : mixed`

##### Parameters

$locale : string

  locale ex. en

$func : callable

#### farthest()

CarbonInterface.php : 2026

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

`public farthest(Carbon|DateTimeInterface|mixed $date1, Carbon|DateTimeInterface|mixed $date2) : static`

##### Parameters

$date1 : Carbon|DateTimeInterface|mixed
$date2 : Carbon|DateTimeInterface|mixed

##### Return values

static

#### firstOfMonth()

CarbonInterface.php : 2038

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

`public firstOfMonth([int|null $dayOfWeek = null ]) : static`

##### Parameters

$dayOfWeek : int|null = null

##### Return values

static

#### firstOfQuarter()

CarbonInterface.php : 2050

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

`public firstOfQuarter([int|null $dayOfWeek = null ]) : static`

##### Parameters

$dayOfWeek : int|null = null

  day of the week default null

##### Return values

static

#### firstOfYear()

CarbonInterface.php : 2062

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

`public firstOfYear([int|null $dayOfWeek = null ]) : static`

##### Parameters

$dayOfWeek : int|null = null

  day of the week default null

##### Return values

static

#### floor()

CarbonInterface.php : 2067

Round the current instance second with given precision if specified.

`public floor([DateInterval|string|int|float $precision = 1 ]) : static`

##### Parameters

$precision : DateInterval|string|int|float = 1

##### Return values

static

#### floorUnit()

CarbonInterface.php : 2072

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

`public floorUnit(string $unit[, DateInterval|string|int|float $precision = 1 ]) : static`

##### Parameters

$unit : string
$precision : DateInterval|string|int|float = 1

##### Return values

static

#### floorWeek()

CarbonInterface.php : 2079

Truncate the current instance week.

`public floorWeek([WeekDay|int|null $weekStartsAt = null ]) : static`

##### Parameters

$weekStartsAt : WeekDay|int|null = null

  optional start allow you to specify the day of week to use to start the week

##### Return values

static

#### from()

CarbonInterface.php : 2115
`public from([Carbon|DateTimeInterface|string|array<string|int, mixed>|null $other = null ][, int|array<string|int, mixed> $syntax = null ][, bool $short = false ][, int $parts = 1 ][, int $options = null ]) : string`

##### Parameters

$other : Carbon|DateTimeInterface|string|array<string|int, mixed>|null = null

  if array passed, will be used as parameters array, see $syntax below; if null passed, now will be used as comparison reference; if any other type, it will be converted to date and used as reference.

$syntax : int|array<string|int, mixed> = null

  if array passed, parameters will be extracted from it, the array may contains:

  - 'syntax' entry (see below)
  - 'short' entry (see below)
  - 'parts' entry (see below)
  - 'options' entry (see below)
  - 'join' entry determines how to join multiple parts of the string `- if $join is a string, it's used as a joiner glue` - if $join is a callable/closure, it get the list of string and should return a string `- if $join is an array, the first item will be the default glue, and the second item` will be used instead of the glue for the last item `- if $join is true, it will be guessed from the locale ('list' translation file entry)` - if $join is missing, a space will be used as glue
  - 'other' entry (see above) if int passed, it add modifiers: Possible values:
  - CarbonInterface::DIFF_ABSOLUTE no modifiers
  - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
  - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier Default value: CarbonInterface::DIFF_ABSOLUTE
$short : bool = false

  displays short format of time units

$parts : int = 1

  maximum number of parts to display (default value: 1: single unit)

$options : int = null

  human diff options

##### Tags

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

##### Return values

string

#### fromNow()

CarbonInterface.php : 2145

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

`public fromNow([int|array<string|int, mixed> $syntax = null ][, bool $short = false ][, int $parts = 1 ][, int $options = null ]) : string`

##### Parameters

$syntax : int|array<string|int, mixed> = null

  if array passed, parameters will be extracted from it, the array may contains:

  - 'syntax' entry (see below)
  - 'short' entry (see below)
  - 'parts' entry (see below)
  - 'options' entry (see below)
  - 'join' entry determines how to join multiple parts of the string `- if $join is a string, it's used as a joiner glue` - if $join is a callable/closure, it get the list of string and should return a string `- if $join is an array, the first item will be the default glue, and the second item` will be used instead of the glue for the last item `- if $join is true, it will be guessed from the locale ('list' translation file entry)` - if $join is missing, a space will be used as glue if int passed, it add modifiers: Possible values:
  - CarbonInterface::DIFF_ABSOLUTE no modifiers
  - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
  - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier Default value: CarbonInterface::DIFF_ABSOLUTE
$short : bool = false

  displays short format of time units

$parts : int = 1

  maximum number of parts to display (default value: 1: single unit)

$options : int = null

  human diff options

##### Return values

string

#### fromSerialized()

CarbonInterface.php : 2156

Create an instance from a serialized string.

`public static fromSerialized(string $value) : static`

##### Parameters

$value : string

##### Tags

throws
  InvalidFormatException

##### Return values

static

#### genericMacro()

CarbonInterface.php : 2166

Register a custom macro.

`public static genericMacro(callable $macro[, int $priority = 0 ]) : void`

##### Parameters

$macro : callable
$priority : int = 0

  marco with higher priority is tried first

#### get()

CarbonInterface.php : 2175

Get a part of the Carbon object.

`public get(Unit|string $name) : string|int|bool|DateTimeZone`

##### Parameters

$name : Unit|string

##### Tags

throws
  UnknownGetterException

##### Return values

string|int|bool|DateTimeZone

#### getAltNumber()

CarbonInterface.php : 2182

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

`public getAltNumber(string $key) : string`

##### Parameters

$key : string

  date property

##### Return values

string

#### getAvailableLocales()

CarbonInterface.php : 2190

Returns the list of internally available locales and already loaded custom locales.

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

(It will ignore custom translator dynamic loading.)

##### Return values

array<string|int, mixed>

#### getAvailableLocalesInfo()

CarbonInterface.php : 2198

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.

`public static getAvailableLocalesInfo() : array<string|int, Language>`

##### Return values

array<string|int, Language>

#### getCalendarFormats()

CarbonInterface.php : 2205

Returns list of calendar formats for ISO formatting.

`public getCalendarFormats([string|null $locale = null ]) : array<string|int, mixed>`

##### Parameters

$locale : string|null = null

  current locale used if null

##### Return values

array<string|int, mixed>

#### getClock()

CarbonInterface.php : 2207
`public getClock() : WrapperClock|null`

##### Return values

WrapperClock|null

#### getDays()

CarbonInterface.php : 2212

Get the days of the week.

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

##### Return values

array<string|int, mixed>

#### getDaysFromStartOfWeek()

CarbonInterface.php : 2222

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

`public getDaysFromStartOfWeek([WeekDay|int|null $weekStartsAt = null ]) : int`

##### Parameters

$weekStartsAt : WeekDay|int|null = null

  optional start allow you to specify the day of week to use to start the week, if not provided, start of week is inferred from the locale (Sunday for en_US, Monday for de_DE, etc.)

##### Return values

int

#### getFallbackLocale()

CarbonInterface.php : 2229

Get the fallback locale.

`public static getFallbackLocale() : string|null`

##### Tags

see
  https://symfony.com/doc/current/components/translation.html#fallback-locales

##### Return values

string|null

#### getFormatsToIsoReplacements()

CarbonInterface.php : 2234

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

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

##### Return values

array<string|int, mixed>

#### getHumanDiffOptions()

CarbonInterface.php : 2239

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

`public static getHumanDiffOptions() : int`

##### Return values

int

#### getIsoFormats()

CarbonInterface.php : 2246

Returns list of locale formats for ISO formatting.

`public getIsoFormats([string|null $locale = null ]) : array<string|int, mixed>`

##### Parameters

$locale : string|null = null

  current locale used if null

##### Return values

array<string|int, mixed>

#### getIsoUnits()

CarbonInterface.php : 2251

Returns list of locale units for ISO formatting.

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

##### Return values

array<string|int, mixed>

#### getLastErrors()

CarbonInterface.php : 2256

{@inheritdoc}

`public static getLastErrors() : array<string|int, mixed>|false`

##### Return values

array<string|int, mixed>|false

#### getLocale()

CarbonInterface.php : 2273

Get the current translator locale.

`public static getLocale() : string`

##### Return values

string

#### getLocalMacro()

CarbonInterface.php : 2261

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

`public getLocalMacro(string $name) : callable|null`

##### Parameters

$name : string

##### Return values

callable|null

#### getLocalTranslator()

CarbonInterface.php : 2266

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

`public getLocalTranslator() : TranslatorInterface`

##### Return values

TranslatorInterface

#### getMacro()

CarbonInterface.php : 2278

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

`public static getMacro(string $name) : callable|null`

##### Parameters

$name : string

##### Return values

callable|null

#### getMidDayAt()

CarbonInterface.php : 2285

get midday/noon hour

`public static getMidDayAt() : int`

##### Return values

int

#### getOffsetString()

CarbonInterface.php : 2295

Returns the offset hour and minute formatted with +/- and a given separator (":" by default).

`public getOffsetString([string $separator = ':' ]) : string`

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".

##### Parameters

$separator : string = ':'

  string to place between hours and minutes (":" by default)

##### Return values

string

#### getPaddedUnit()

CarbonInterface.php : 2305

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

`public getPaddedUnit(string $unit[, int $length = 2 ][, string $padString = '0' ][, int $padType = 0 ]) : string`

##### Parameters

$unit : string

  Carbon unit name

$length : int = 2

  Length of the output (2 by default)

$padString : string = '0'

  String to use for padding ("0" by default)

$padType : int = 0

  Side(s) to pad (STR_PAD_LEFT by default)

##### Return values

string

#### getPreciseTimestamp()

CarbonInterface.php : 2325

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

`public getPreciseTimestamp([int $precision = 6 ]) : float`

##### Parameters

$precision : int = 6

##### Tags

example

  getPreciseTimestamp() 1532087464437474 (microsecond maximum precision)

example

  getPreciseTimestamp(6) 1532087464437474

example

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

example

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

example

  getPreciseTimestamp(3) 1532087464437 (millisecond precision)

example

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

example

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

example

  getPreciseTimestamp(0) 1532087464 (second precision)

example

  getPreciseTimestamp(-1) 153208746 (10 second precision)

example

  getPreciseTimestamp(-2) 15320875 (100 second precision)

##### Return values

float

#### getSettings()

CarbonInterface.php : 2330

Returns current local settings.

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

##### Return values

array<string|int, mixed>

#### getTestNow()

CarbonInterface.php : 2338

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

`public static getTestNow() : Closure|self|null`

##### Return values

Closure|self|null —

the current instance used for testing

#### getTimeFormatByPrecision()

CarbonInterface.php : 2345

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

`public static getTimeFormatByPrecision(string $unitPrecision) : string`

##### Parameters

$unitPrecision : string

  "minute", "second", "millisecond" or "microsecond"

##### Return values

string

#### getTimestampMs()

CarbonInterface.php : 2352

Returns the timestamp with millisecond precision.

`public getTimestampMs() : int`

##### Return values

int

#### getTranslatedDayName()

CarbonInterface.php : 2361

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

`public getTranslatedDayName([string|null $context = null ][, string $keySuffix = '' ][, string|null $defaultValue = null ]) : string`

##### Parameters

$context : string|null = null

  whole format string

$keySuffix : string = ''

  "", "_short" or "_min"

$defaultValue : string|null = null

  default value if translation missing

##### Return values

string

#### getTranslatedMinDayName()

CarbonInterface.php : 2368

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

`public getTranslatedMinDayName([string|null $context = null ]) : string`

##### Parameters

$context : string|null = null

  whole format string

##### Return values

string

#### getTranslatedMonthName()

CarbonInterface.php : 2377

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

`public getTranslatedMonthName([string|null $context = null ][, string $keySuffix = '' ][, string|null $defaultValue = null ]) : string`

##### Parameters

$context : string|null = null

  whole format string

$keySuffix : string = ''

  "" or "_short"

$defaultValue : string|null = null

  default value if translation missing

##### Return values

string

#### getTranslatedShortDayName()

CarbonInterface.php : 2384

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

`public getTranslatedShortDayName([string|null $context = null ]) : string`

##### Parameters

$context : string|null = null

  whole format string

##### Return values

string

#### getTranslatedShortMonthName()

CarbonInterface.php : 2391

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

`public getTranslatedShortMonthName([string|null $context = null ]) : string`

##### Parameters

$context : string|null = null

  whole format string

##### Return values

string

#### getTranslationMessage()

CarbonInterface.php : 2403

Returns raw translation message for a given key.

`public getTranslationMessage(string $key[, string|null $locale = null ][, string|null $default = null ][, TranslatorInterface $translator = null ]) : string`

##### Parameters

$key : string

  key to find

$locale : string|null = null

  current locale used if null

$default : string|null = null

  default value if translation returns the key

$translator : TranslatorInterface = null

  an optional translator to use

##### Return values

string

#### getTranslationMessageWith()

CarbonInterface.php : 2415

Returns raw translation message for a given key.

`public static getTranslationMessageWith(TranslatorInterface|null $translator, string $key[, string|null $locale = null ][, string|null $default = null ]) : string|Closure|null`

##### Parameters

$translator : TranslatorInterface|null

  the translator to use

$key : string

  key to find

$locale : string|null = null

  current locale used if null

$default : string|null = null

  default value if translation returns the key

##### Return values

string|Closure|null

#### getTranslator()

CarbonInterface.php : 2420

Initialize the default translator instance if necessary.

`public static getTranslator() : TranslatorInterface`

##### Return values

TranslatorInterface

#### getWeekendDays()

CarbonInterface.php : 2441

Get weekend days

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

##### Return values

array<string|int, mixed>

#### getWeekEndsAt()

CarbonInterface.php : 2429

Get the last day of week.

`public static getWeekEndsAt([string $locale = null ]) : int`

##### Parameters

$locale : string = null

  local to consider the last day of week.

##### Return values

int

#### getWeekStartsAt()

CarbonInterface.php : 2436

Get the first day of week.

`public static getWeekStartsAt([string|null $locale = null ]) : int`

##### Parameters

$locale : string|null = null

##### Return values

int

#### greaterThan()

CarbonInterface.php : 2453

Determines if the instance is greater (after) than another

`public greaterThan(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      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

##### Return values

bool

#### greaterThanOrEqualTo()

CarbonInterface.php : 2465

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

`public greaterThanOrEqualTo(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      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

##### Return values

bool

#### gt()

CarbonInterface.php : 2479

Determines if the instance is greater (after) than another

`public gt(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      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

see
  greaterThan()

##### Return values

bool

#### gte()

CarbonInterface.php : 2493

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

`public gte(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      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

see
  greaterThanOrEqualTo()

##### Return values

bool

#### hasFormat()

CarbonInterface.php : 2504

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

`public static hasFormat(string $date, string $format) : bool`

##### Parameters

$date : string
$format : string

##### Tags

example

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

##### Return values

bool

#### hasFormatWithModifiers()

CarbonInterface.php : 2520

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

`public static hasFormatWithModifiers(string $date, string $format) : bool`

##### Parameters

$date : string
$format : string

##### Tags

example

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

##### Return values

bool

#### hasLocalMacro()

CarbonInterface.php : 2525

Checks if macro is registered globally or locally.

`public hasLocalMacro(string $name) : bool`

##### Parameters

$name : string

##### Return values

bool

#### hasLocalTranslator()

CarbonInterface.php : 2530

Return true if the current instance has its own translator.

`public hasLocalTranslator() : bool`

##### Return values

bool

#### hasMacro()

CarbonInterface.php : 2539

Checks if macro is registered globally.

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

##### Parameters

$name : string

##### Return values

bool

#### hasRelativeKeywords()

CarbonInterface.php : 2546

Determine if a time string will produce a relative date.

`public static hasRelativeKeywords(string|null $time) : bool`

##### Parameters

$time : string|null

##### Return values

bool —

true if time match a relative date, false if absolute or invalid time string

#### hasTestNow()

CarbonInterface.php : 2554

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

`public static hasTestNow() : bool`

##### Return values

bool —

true if there is a test instance, otherwise false

#### instance()

CarbonInterface.php : 2559

Create a Carbon instance from a DateTime one.

`public static instance(DateTimeInterface $date) : static`

##### Parameters

$date : DateTimeInterface

##### Return values

static

#### is()

CarbonInterface.php : 2583

Returns true if the current date matches the given string.

`public is(string $tester) : bool`

##### Parameters

$tester : string

  day name, month name, hour, date, etc. as string

##### Tags

example

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

##### Return values

bool

#### isAfter()

CarbonInterface.php : 2597

Determines if the instance is greater (after) than another

`public isAfter(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      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

see
  greaterThan()

##### Return values

bool

#### isBefore()

CarbonInterface.php : 2611

Determines if the instance is less (before) than another

`public isBefore(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      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

see
  lessThan()

##### Return values

bool

#### isBetween()

CarbonInterface.php : 2626

Determines if the instance is between two others

`public isBetween(DateTimeInterface|string $date1, DateTimeInterface|string $date2[, bool $equal = true ]) : bool`

##### Parameters

$date1 : DateTimeInterface|string
$date2 : DateTimeInterface|string
$equal : bool = true

  Indicates if an equal to comparison should be done

##### Tags

example

      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

##### Return values

bool

#### isBirthday()

CarbonInterface.php : 2643

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

`public isBirthday([DateTimeInterface|string|null $date = null ]) : bool`

##### Parameters

$date : DateTimeInterface|string|null = null

  The instance to compare with or null to use current day.

##### Tags

example

      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

##### Return values

bool

#### isCurrentUnit()

CarbonInterface.php : 2658

Determines if the instance is in the current unit given.

`public isCurrentUnit(string $unit) : bool`

##### Parameters

$unit : string

  The unit to test.

##### Tags

example

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

throws
  BadMethodCallException

##### Return values

bool

#### isDayOfWeek()

CarbonInterface.php : 2675

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

`public isDayOfWeek(int|string $dayOfWeek) : bool`

##### Parameters

$dayOfWeek : int|string

##### Tags

example

      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

##### Return values

bool

#### isEndOfCentury()

CarbonInterface.php : 2680

Determines if the instance is end of century (last day by default but interval can be customized).

`public isEndOfCentury([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfDay()

CarbonInterface.php : 2702

Check if the instance is end of day.

`public isEndOfDay([bool $checkMicroseconds = false ][, Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$checkMicroseconds : bool = false

  check time at microseconds precision

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

  if an interval is specified it will be used as precision for instance with "15 minutes", it checks if current date-time is in the last 15 minutes of the day, with Unit::Hour, it checks if it's in the last hour of the day.

##### Tags

example

      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

##### Return values

bool

#### isEndOfDecade()

CarbonInterface.php : 2707

Determines if the instance is end of decade (last day by default but interval can be customized).

`public isEndOfDecade([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfHour()

CarbonInterface.php : 2712

Determines if the instance is end of hour (last microsecond by default but interval can be customized).

`public isEndOfHour([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfMillennium()

CarbonInterface.php : 2717

Determines if the instance is end of millennium (last day by default but interval can be customized).

`public isEndOfMillennium([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfMillisecond()

CarbonInterface.php : 2722

Determines if the instance is end of millisecond (last microsecond by default but interval can be customized).

`public isEndOfMillisecond([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfMinute()

CarbonInterface.php : 2727

Determines if the instance is end of minute (last microsecond by default but interval can be customized).

`public isEndOfMinute([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfMonth()

CarbonInterface.php : 2732

Determines if the instance is end of month (last day by default but interval can be customized).

`public isEndOfMonth([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfQuarter()

CarbonInterface.php : 2737

Determines if the instance is end of quarter (last day by default but interval can be customized).

`public isEndOfQuarter([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfSecond()

CarbonInterface.php : 2742

Determines if the instance is end of second (last microsecond by default but interval can be customized).

`public isEndOfSecond([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfTime()

CarbonInterface.php : 2749

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

`public isEndOfTime() : bool`

##### Return values

bool

#### isEndOfUnit()

CarbonInterface.php : 2760

Check if the instance is end of a given unit (tolerating a given interval).

`public isEndOfUnit(Unit $unit[, Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ], mixed ...$params) : bool`

##### Parameters

$unit : Unit
$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null
$params : mixed

##### Tags

example

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

##### Return values

bool

#### isEndOfWeek()

CarbonInterface.php : 2771

Determines if the instance is end of week (last day by default but interval can be customized).

`public isEndOfWeek([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ][, WeekDay|int|null $weekEndsAt = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null
$weekEndsAt : WeekDay|int|null = null

##### Tags

example

      Carbon::parse('2024-08-31')->endOfWeek()->isEndOfWeek(); // true
      Carbon::parse('2024-08-31')->isEndOfWeek(); // false

##### Return values

bool

#### isEndOfYear()

CarbonInterface.php : 2776

Determines if the instance is end of year (last day by default but interval can be customized).

`public isEndOfYear([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isFuture()

CarbonInterface.php : 2787

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

`public isFuture() : bool`

##### Tags

example

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

##### Return values

bool

#### isImmutable()

CarbonInterface.php : 2792

Returns true if the current class/instance is immutable.

`public static isImmutable() : bool`

##### Return values

bool

#### isLastOfMonth()

CarbonInterface.php : 2806

Check if today is the last day of the Month

`public isLastOfMonth() : bool`

##### Tags

example

      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

##### Return values

bool

#### isLeapYear()

CarbonInterface.php : 2817

Determines if the instance is a leap year.

`public isLeapYear() : bool`

##### Tags

example

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

##### Return values

bool

#### isLongIsoYear()

CarbonInterface.php : 2833

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

`public isLongIsoYear() : bool`

##### Tags

example

      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

see
  https://en.wikipedia.org/wiki/ISO_8601#Week_dates

##### Return values

bool

#### isLongYear()

CarbonInterface.php : 2851

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

`public isLongYear() : bool`

⚠️ 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.

##### Tags

example

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

see
  https://en.wikipedia.org/wiki/ISO_8601#Week_dates

##### Return values

bool

#### isMidday()

CarbonInterface.php : 2864

Check if the instance is midday.

`public isMidday() : bool`

##### Tags

example

      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

##### Return values

bool

#### isMidnight()

CarbonInterface.php : 2876

Check if the instance is start of day / midnight.

`public isMidnight() : bool`

##### Tags

example

      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

##### Return values

bool

#### isModifiableUnit()

CarbonInterface.php : 2885

Returns true if a property can be changed via setter.

`public static isModifiableUnit(string $unit) : bool`

##### Parameters

$unit : string

##### Return values

bool

#### isMutable()

CarbonInterface.php : 2890

Returns true if the current class/instance is mutable.

`public static isMutable() : bool`

##### Return values

bool

#### isoFormat()

CarbonInterface.php : 3138

Format in the current language using ISO replacement patterns.

`public isoFormat(string $format[, string|null $originalFormat = null ]) : string`

##### Parameters

$format : string
$originalFormat : string|null = null

  provide context if a chunk has been passed alone

##### Return values

string

#### isoWeek()

CarbonInterface.php : 3151

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

`public isoWeek([int|null $week = null ][, int|null $dayOfWeek = null ][, int|null $dayOfYear = null ]) : int|static`

##### Parameters

$week : int|null = null
$dayOfWeek : int|null = null
$dayOfYear : int|null = null

##### Return values

int|static

#### isoWeekday()

CarbonInterface.php : 3171

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

`public isoWeekday([WeekDay|int|null $value = null ]) : static|int`

##### Parameters

$value : WeekDay|int|null = null

  new value for weekday if using as setter.

##### Return values

static|int

#### isoWeeksInYear()

CarbonInterface.php : 3183

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

`public isoWeeksInYear([int|null $dayOfWeek = null ][, int|null $dayOfYear = null ]) : int`

##### Parameters

$dayOfWeek : int|null = null

  first date of week from 0 (Sunday) to 6 (Saturday)

$dayOfYear : int|null = null

  first day of year included in the week #1

##### Return values

int

#### isoWeekYear()

CarbonInterface.php : 3164

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

`public isoWeekYear([int|null $year = null ][, int|null $dayOfWeek = null ][, int|null $dayOfYear = null ]) : int|static`

##### Parameters

$year : int|null = null

  if null, act as a getter, if not null, set the year and return current instance.

$dayOfWeek : int|null = null

  first date of week from 0 (Sunday) to 6 (Saturday)

$dayOfYear : int|null = null

  first day of year included in the week #1

##### Return values

int|static

#### isPast()

CarbonInterface.php : 2901

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

`public isPast() : bool`

##### Tags

example

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

##### Return values

bool

#### isSameAs()

CarbonInterface.php : 2915

Compares the formatted values of the two dates.

`public isSameAs(string $format, DateTimeInterface|string $date) : bool`

##### Parameters

$format : string

  date formats to compare.

$date : DateTimeInterface|string

  instance to compare with or null to use current day.

##### Tags

example

      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

##### Return values

bool

#### isSameMonth()

CarbonInterface.php : 2933

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

`public isSameMonth(DateTimeInterface|string $date[, bool $ofSameYear = true ]) : bool`

##### Parameters

$date : DateTimeInterface|string

  The instance to compare with or null to use the current date.

$ofSameYear : bool = true

  Check if it is the same month in the same year.

##### Tags

example

      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

##### Return values

bool

#### isSameQuarter()

CarbonInterface.php : 2951

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

`public isSameQuarter(DateTimeInterface|string $date[, bool $ofSameYear = true ]) : bool`

##### Parameters

$date : DateTimeInterface|string

  The instance to compare with or null to use current day.

$ofSameYear : bool = true

  Check if it is the same month in the same year.

##### Tags

example

      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

##### Return values

bool

#### isSameUnit()

CarbonInterface.php : 2969

Determines if the instance is in the current unit given.

`public isSameUnit(string $unit, DateTimeInterface|string $date) : bool`

##### Parameters

$unit : string

  singular unit string

$date : DateTimeInterface|string

  instance to compare with or null to use current day.

##### Tags

example

      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

throws
  BadComparisonUnitException

##### Return values

bool

#### isStartOfCentury()

CarbonInterface.php : 2974

Determines if the instance is start of century (first day by default but interval can be customized).

`public isStartOfCentury([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfDay()

CarbonInterface.php : 2994

Check if the instance is start of day / midnight.

`public isStartOfDay([bool $checkMicroseconds = false ][, Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$checkMicroseconds : bool = false

  check time at microseconds precision

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

  if an interval is specified it will be used as precision for instance with "15 minutes", it checks if current date-time is in the last 15 minutes of the day, with Unit::Hour, it checks if it's in the last hour of the day.

##### Tags

example

      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

##### Return values

bool

#### isStartOfDecade()

CarbonInterface.php : 2999

Determines if the instance is start of decade (first day by default but interval can be customized).

`public isStartOfDecade([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfHour()

CarbonInterface.php : 3004

Determines if the instance is start of hour (first microsecond by default but interval can be customized).

`public isStartOfHour([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfMillennium()

CarbonInterface.php : 3009

Determines if the instance is start of millennium (first day by default but interval can be customized).

`public isStartOfMillennium([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfMillisecond()

CarbonInterface.php : 3014

Determines if the instance is start of millisecond (first microsecond by default but interval can be customized).

`public isStartOfMillisecond([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfMinute()

CarbonInterface.php : 3019

Determines if the instance is start of minute (first microsecond by default but interval can be customized).

`public isStartOfMinute([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfMonth()

CarbonInterface.php : 3024

Determines if the instance is start of month (first day by default but interval can be customized).

`public isStartOfMonth([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfQuarter()

CarbonInterface.php : 3029

Determines if the instance is start of quarter (first day by default but interval can be customized).

`public isStartOfQuarter([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfSecond()

CarbonInterface.php : 3034

Determines if the instance is start of second (first microsecond by default but interval can be customized).

`public isStartOfSecond([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfTime()

CarbonInterface.php : 3041

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

`public isStartOfTime() : bool`

##### Return values

bool

#### isStartOfUnit()

CarbonInterface.php : 3052

Check if the instance is start of a given unit (tolerating a given interval).

`public isStartOfUnit(Unit $unit[, Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ], mixed ...$params) : bool`

##### Parameters

$unit : Unit
$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null
$params : mixed

##### Tags

example

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

##### Return values

bool

#### isStartOfWeek()

CarbonInterface.php : 3063

Determines if the instance is start of week (first day by default but interval can be customized).

`public isStartOfWeek([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ][, WeekDay|int|null $weekStartsAt = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null
$weekStartsAt : WeekDay|int|null = null

##### Tags

example

      Carbon::parse('2024-08-31')->startOfWeek()->isStartOfWeek(); // true
      Carbon::parse('2024-08-31')->isStartOfWeek(); // false

##### Return values

bool

#### isStartOfYear()

CarbonInterface.php : 3068

Determines if the instance is start of year (first day by default but interval can be customized).

`public isStartOfYear([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStrictModeEnabled()

CarbonInterface.php : 3076

Returns true if the strict mode is globally in use, false else.

`public static isStrictModeEnabled() : bool`

(It can be overridden in specific instances.)

##### Return values

bool

#### isToday()

CarbonInterface.php : 3087

Determines if the instance is today.

`public isToday() : bool`

##### Tags

example

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

##### Return values

bool

#### isTomorrow()

CarbonInterface.php : 3098

Determines if the instance is tomorrow.

`public isTomorrow() : bool`

##### Tags

example

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

##### Return values

bool

#### isWeekday()

CarbonInterface.php : 3109

Determines if the instance is a weekday.

`public isWeekday() : bool`

##### Tags

example

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

##### Return values

bool

#### isWeekend()

CarbonInterface.php : 3120

Determines if the instance is a weekend day.

`public isWeekend() : bool`

##### Tags

example

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

##### Return values

bool

#### isYesterday()

CarbonInterface.php : 3131

Determines if the instance is yesterday.

`public isYesterday() : bool`

##### Tags

example

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

##### Return values

bool

#### jsonSerialize()

CarbonInterface.php : 3188

Prepare the object for JSON serialization.

`public jsonSerialize() : mixed`

#### lastOfMonth()

CarbonInterface.php : 3200

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

`public lastOfMonth([int|null $dayOfWeek = null ]) : static`

##### Parameters

$dayOfWeek : int|null = null

##### Return values

static

#### lastOfQuarter()

CarbonInterface.php : 3212

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

`public lastOfQuarter([int|null $dayOfWeek = null ]) : static`

##### Parameters

$dayOfWeek : int|null = null

  day of the week default null

##### Return values

static

#### lastOfYear()

CarbonInterface.php : 3224

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

`public lastOfYear([int|null $dayOfWeek = null ]) : static`

##### Parameters

$dayOfWeek : int|null = null

  day of the week default null

##### Return values

static

#### lessThan()

CarbonInterface.php : 3236

Determines if the instance is less (before) than another

`public lessThan(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      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

##### Return values

bool

#### lessThanOrEqualTo()

CarbonInterface.php : 3248

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

`public lessThanOrEqualTo(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      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

##### Return values

bool

#### locale()

CarbonInterface.php : 3258

Get/set the locale for the current instance.

`public locale([string|null $locale = null ], string ...$fallbackLocales) : $this|string`

##### Parameters

$locale : string|null = null
$fallbackLocales : string

##### Return values

$this|string

#### localeHasDiffOneDayWords()

CarbonInterface.php : 3268

Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).

`public static localeHasDiffOneDayWords(string $locale) : bool`

Support is considered enabled if the 3 words are translated in the given locale.

##### Parameters

$locale : string

  locale ex. en

##### Return values

bool

#### localeHasDiffSyntax()

CarbonInterface.php : 3278

Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).

`public static localeHasDiffSyntax(string $locale) : bool`

Support is considered enabled if the 4 sentences are translated in the given locale.

##### Parameters

$locale : string

  locale ex. en

##### Return values

bool

#### localeHasDiffTwoDayWords()

CarbonInterface.php : 3288

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

`public static localeHasDiffTwoDayWords(string $locale) : bool`

Support is considered enabled if the 2 words are translated in the given locale.

##### Parameters

$locale : string

  locale ex. en

##### Return values

bool

#### localeHasPeriodSyntax()

CarbonInterface.php : 3298

Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).

`public static localeHasPeriodSyntax(string $locale) : bool`

Support is considered enabled if the 4 sentences are translated in the given locale.

##### Parameters

$locale : string

  locale ex. en

##### Return values

bool

#### localeHasShortUnits()

CarbonInterface.php : 3308

Returns true if the given locale is internally supported and has short-units support.

`public static localeHasShortUnits(string $locale) : bool`

Support is considered enabled if either year, day or hour has a short variant translated.

##### Parameters

$locale : string

  locale ex. en

##### Return values

bool

#### lt()

CarbonInterface.php : 3322

Determines if the instance is less (before) than another

`public lt(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      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

see
  lessThan()

##### Return values

bool

#### lte()

CarbonInterface.php : 3336

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

`public lte(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      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

see
  lessThanOrEqualTo()

##### Return values

bool

#### macro()

CarbonInterface.php : 3355

Register a custom macro.

`public static macro(string $name, callable|null $macro) : void`

Pass null macro to remove it.

##### Parameters

$name : string
$macro : callable|null

##### Tags

example

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

#### make()

CarbonInterface.php : 3369

Make a Carbon instance from given variable if possible.

`public static make(mixed $var[, DateTimeZone|string|null $timezone = null ]) : static|null`

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.

##### Parameters

$var : mixed
$timezone : DateTimeZone|string|null = null

##### Tags

throws
  InvalidFormatException

##### Return values

static|null

#### max()

CarbonInterface.php : 3378

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

`public max([Carbon|DateTimeInterface|mixed $date = null ]) : static`

##### Parameters

$date : Carbon|DateTimeInterface|mixed = null

##### Return values

static

#### maximum()

CarbonInterface.php : 3389

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

`public maximum([Carbon|DateTimeInterface|mixed $date = null ]) : static`

##### Parameters

$date : Carbon|DateTimeInterface|mixed = null

##### Tags

see
  max()

##### Return values

static

#### meridiem()

CarbonInterface.php : 3396

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

`public meridiem([bool $isLower = false ]) : string`

##### Parameters

$isLower : bool = false

  if true, returns lowercase variant if available in the current locale.

##### Return values

string

#### midDay()

CarbonInterface.php : 3403

Modify to midday, default to self::$midDayAt

`public midDay() : static`

##### Return values

static

#### min()

CarbonInterface.php : 3412

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

`public min([Carbon|DateTimeInterface|mixed $date = null ]) : static`

##### Parameters

$date : Carbon|DateTimeInterface|mixed = null

##### Return values

static

#### minimum()

CarbonInterface.php : 3423

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

`public minimum([Carbon|DateTimeInterface|mixed $date = null ]) : static`

##### Parameters

$date : Carbon|DateTimeInterface|mixed = null

##### Tags

see
  min()

##### Return values

static

#### mixin()

CarbonInterface.php : 3452

Mix another object into the class.

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

##### Parameters

$mixin : object|string

##### Tags

example

      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";

throws
  ReflectionException

#### modify()

CarbonInterface.php : 3461

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

`public modify(mixed $modify) : static`

##### Parameters

$modify : mixed

##### Tags

see
  https://php.net/manual/en/datetime.modify.php

##### Return values

static

#### ne()

CarbonInterface.php : 3476

Determines if the instance is not equal to another

`public ne(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      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

see
  notEqualTo()

##### Return values

bool

#### next()

CarbonInterface.php : 3488

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

`public next([string|int|null $modifier = null ]) : static`

##### Parameters

$modifier : string|int|null = null

##### Return values

static

#### nextWeekday()

CarbonInterface.php : 3495

Go forward to the next weekday.

`public nextWeekday() : static`

##### Return values

static

#### nextWeekendDay()

CarbonInterface.php : 3502

Go forward to the next weekend day.

`public nextWeekendDay() : static`

##### Return values

static

#### notEqualTo()

CarbonInterface.php : 3514

Determines if the instance is not equal to another

`public notEqualTo(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      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

##### Return values

bool

#### now()

CarbonInterface.php : 3519

Get a Carbon instance for the current date and time.

`public static now([DateTimeZone|string|int|null $timezone = null ]) : static`

##### Parameters

$timezone : DateTimeZone|string|int|null = null

##### Return values

static

#### nowWithSameTz()

CarbonInterface.php : 3526

Returns a present instance in the same timezone.

`public nowWithSameTz() : static`

##### Return values

static

#### nthOfMonth()

CarbonInterface.php : 3539

Modify to the given occurrence of a given day of the week in the current month. If the calculated occurrence is outside the scope of the current month, then return false and no modifications are made.

`public nthOfMonth(int $nth, int $dayOfWeek) : mixed`

Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

##### Parameters

$nth : int
$dayOfWeek : int

#### nthOfQuarter()

CarbonInterface.php : 3552

Modify to the given occurrence of a given day of the week in the current quarter. If the calculated occurrence is outside the scope of the current quarter, then return false and no modifications are made.

`public nthOfQuarter(int $nth, int $dayOfWeek) : mixed`

Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

##### Parameters

$nth : int
$dayOfWeek : int

#### nthOfYear()

CarbonInterface.php : 3565

Modify to the given occurrence of a given day of the week in the current year. If the calculated occurrence is outside the scope of the current year, then return false and no modifications are made.

`public nthOfYear(int $nth, int $dayOfWeek) : mixed`

Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

##### Parameters

$nth : int
$dayOfWeek : int

#### ordinal()

CarbonInterface.php : 3570

Return a property with its ordinal.

`public ordinal(string $key[, string|null $period = null ]) : string`

##### Parameters

$key : string
$period : string|null = null

##### Return values

string

#### parse()

CarbonInterface.php : 3581

Create a carbon instance from a string.

`public static parse(DateTimeInterface|WeekDay|Month|string|int|float|null $time[, DateTimeZone|string|int|null $timezone = null ]) : static`

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

##### Parameters

$time : DateTimeInterface|WeekDay|Month|string|int|float|null
$timezone : DateTimeZone|string|int|null = null

##### Tags

throws
  InvalidFormatException

##### Return values

static

#### parseFromLocale()

CarbonInterface.php : 3593

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

`public static parseFromLocale(string $time[, string|null $locale = null ][, DateTimeZone|string|int|null $timezone = null ]) : static`

##### Parameters

$time : string

  date/time string in the given language (may also contain English).

$locale : string|null = null

  if locale is null or not specified, current global locale will be used instead.

$timezone : DateTimeZone|string|int|null = null

  optional timezone for the new instance.

##### Tags

throws
  InvalidFormatException

##### Return values

static

#### pluralUnit()

CarbonInterface.php : 3598

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

`public static pluralUnit(string $unit) : string`

##### Parameters

$unit : string

##### Return values

string

#### previous()

CarbonInterface.php : 3610

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

`public previous([string|int|null $modifier = null ]) : static`

##### Parameters

$modifier : string|int|null = null

##### Return values

static

#### previousWeekday()

CarbonInterface.php : 3617

Go backward to the previous weekday.

`public previousWeekday() : static`

##### Return values

static

#### previousWeekendDay()

CarbonInterface.php : 3624

Go backward to the previous weekend day.

`public previousWeekendDay() : static`

##### Return values

static

#### range()

CarbonInterface.php : 3633

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

`public range([DateTimeInterface|Carbon|CarbonImmutable|null $end = null ][, int|DateInterval|string|null $interval = null ][, string|null $unit = null ]) : CarbonPeriod`

##### Parameters

$end : DateTimeInterface|Carbon|CarbonImmutable|null = null

  period end date

$interval : int|DateInterval|string|null = null

  period default interval or number of the given $unit

$unit : string|null = null

  if specified, $interval must be an integer

##### Return values

CarbonPeriod

#### rawAdd()

CarbonInterface.php : 3642

Call native PHP DateTime/DateTimeImmutable add() method.

`public rawAdd(DateInterval $interval) : static`

##### Parameters

$interval : DateInterval

##### Return values

static

#### rawCreateFromFormat()

CarbonInterface.php : 3655

Create a Carbon instance from a specific format.

`public static rawCreateFromFormat(string $format, string $time[, DateTimeZone|string|int|null $timezone = null ]) : static|null`

##### Parameters

$format : string

  Datetime format

$time : string
$timezone : DateTimeZone|string|int|null = null

##### Tags

throws
  InvalidFormatException

##### Return values

static|null

#### rawFormat()

CarbonInterface.php : 3660
`public rawFormat(string $format) : string`

##### Parameters

$format : string

##### Tags

see
  https://php.net/manual/en/datetime.format.php

##### Return values

string

#### rawParse()

CarbonInterface.php : 3671

Create a carbon instance from a string.

`public static rawParse(DateTimeInterface|WeekDay|Month|string|int|float|null $time[, DateTimeZone|string|int|null $timezone = null ]) : static`

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

##### Parameters

$time : DateTimeInterface|WeekDay|Month|string|int|float|null
$timezone : DateTimeZone|string|int|null = null

##### Tags

throws
  InvalidFormatException

##### Return values

static

#### rawSub()

CarbonInterface.php : 3676

Call native PHP DateTime/DateTimeImmutable sub() method.

`public rawSub(DateInterval $interval) : static`

##### Parameters

$interval : DateInterval

##### Return values

static

#### resetMacros()

CarbonInterface.php : 3681

Remove all macros and generic macros.

`public static resetMacros() : void`

#### resetMonthsOverflow()

CarbonInterface.php : 3694
`public static resetMonthsOverflow() : void`

##### Tags

deprecated

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

see
  settings

  Reset the month overflow behavior.

#### resetToStringFormat()

CarbonInterface.php : 3701

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

`public static resetToStringFormat() : void`

#### resetYearsOverflow()

CarbonInterface.php : 3714
`public static resetYearsOverflow() : void`

##### Tags

deprecated

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

see
  settings

  Reset the month overflow behavior.

#### round()

CarbonInterface.php : 3719

Round the current instance second with given precision if specified.

`public round([DateInterval|string|int|float $precision = 1 ][, callable|string $function = 'round' ]) : static`

##### Parameters

$precision : DateInterval|string|int|float = 1
$function : callable|string = 'round'

##### Return values

static

#### roundUnit()

CarbonInterface.php : 3724

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

`public roundUnit(string $unit[, DateInterval|string|int|float $precision = 1 ][, callable|string $function = 'round' ]) : static`

##### Parameters

$unit : string
$precision : DateInterval|string|int|float = 1
$function : callable|string = 'round'

##### Return values

static

#### roundWeek()

CarbonInterface.php : 3731

Round the current instance week.

`public roundWeek([WeekDay|int|null $weekStartsAt = null ]) : static`

##### Parameters

$weekStartsAt : WeekDay|int|null = null

  optional start allow you to specify the day of week to use to start the week

##### Return values

static

#### secondsSinceMidnight()

CarbonInterface.php : 3738

The number of seconds since midnight.

`public secondsSinceMidnight() : float`

##### Return values

float

#### secondsUntilEndOfDay()

CarbonInterface.php : 3745

The number of seconds until 23:59:59.

`public secondsUntilEndOfDay() : float`

##### Return values

float

#### serialize()

CarbonInterface.php : 3750

Return a serialized string of the instance.

`public serialize() : string`

##### Return values

string

#### serializeUsing()

CarbonInterface.php : 3758
`public static serializeUsing(callable|string|null $format) : void`

##### Parameters

$format : callable|string|null

##### Tags

deprecated

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

  JSON serialize all Carbon instances using the given callback.

#### set()

CarbonInterface.php : 3767

Set a part of the Carbon object.

`public set(Unit|array<string|int, mixed>|string $name[, DateTimeZone|Month|string|int|float|null $value = null ]) : $this`

##### Parameters

$name : Unit|array<string|int, mixed>|string
$value : DateTimeZone|Month|string|int|float|null = null

##### Tags

throws
  ImmutableException|UnknownSetterException

##### Return values

$this

#### setDate()

CarbonInterface.php : 3774

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

`public setDate(int $year, int $month, int $day) : static`

##### Parameters

$year : int
$month : int
$day : int

##### Tags

see
  https://php.net/manual/en/datetime.setdate.php

##### Return values

static

#### setDateFrom()

CarbonInterface.php : 3779

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

`public setDateFrom(DateTimeInterface|string $date) : static`

##### Parameters

$date : DateTimeInterface|string

##### Return values

static

#### setDateTime()

CarbonInterface.php : 3784

Set the date and time all together.

`public setDateTime(int $year, int $month, int $day, int $hour, int $minute[, int $second = 0 ][, int $microseconds = 0 ]) : static`

##### Parameters

$year : int
$month : int
$day : int
$hour : int
$minute : int
$second : int = 0
$microseconds : int = 0

##### Return values

static

#### setDateTimeFrom()

CarbonInterface.php : 3789

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

`public setDateTimeFrom(DateTimeInterface|string $date) : static`

##### Parameters

$date : DateTimeInterface|string

##### Return values

static

#### setDaysFromStartOfWeek()

CarbonInterface.php : 3800

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

`public setDaysFromStartOfWeek(int $numberOfDays[, WeekDay|int|null $weekStartsAt = null ]) : static`

##### Parameters

$numberOfDays : int

  number of days to add after the start of the current week

$weekStartsAt : WeekDay|int|null = null

  optional start allow you to specify the day of week to use to start the week, if not provided, start of week is inferred from the locale (Sunday for en_US, Monday for de_DE, etc.)

##### Return values

static

#### setFallbackLocale()

CarbonInterface.php : 3809

Set the fallback locale.

`public static setFallbackLocale(string $locale) : void`

##### Parameters

$locale : string

##### Tags

see
  https://symfony.com/doc/current/components/translation.html#fallback-locales

#### setHumanDiffOptions()

CarbonInterface.php : 3816
`public static setHumanDiffOptions(int $humanDiffOptions) : void`

##### Parameters

$humanDiffOptions : int

##### Tags

deprecated

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

see
  settings

#### setISODate()

CarbonInterface.php : 3823

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

`public setISODate(int $year, int $week[, int $day = 1 ]) : static`

##### Parameters

$year : int
$week : int
$day : int = 1

##### Tags

see
  https://php.net/manual/en/datetime.setisodate.php

##### Return values

static

#### setLocale()

CarbonInterface.php : 3836

Set the current translator locale and indicate if the source locale file exists.

`public static setLocale(string $locale) : void`

Pass 'auto' as locale to use the closest language to the current LC_TIME locale.

##### Parameters

$locale : string

  locale ex. en

#### setLocalTranslator()

CarbonInterface.php : 3828

Set the translator for the current instance.

`public setLocalTranslator(TranslatorInterface $translator) : mixed`

##### Parameters

$translator : TranslatorInterface

#### setMidDayAt()

CarbonInterface.php : 3852
`public static setMidDayAt(int $hour) : void`

##### Parameters

$hour : int

  midday hour

##### Tags

deprecated

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

  Set midday/noon hour

#### setTestNow()

CarbonInterface.php : 3876

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

`public static setTestNow([DateTimeInterface|Closure|static|string|false|null $testNow = null ]) : void`

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.

##### Parameters

$testNow : DateTimeInterface|Closure|static|string|false|null = null

  real or mock Carbon instance

#### setTestNowAndTimezone()

CarbonInterface.php : 3897

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

`public static setTestNowAndTimezone([DateTimeInterface|Closure|static|string|false|null $testNow = null ][, mixed $timezone = null ]) : void`

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.

##### Parameters

$testNow : DateTimeInterface|Closure|static|string|false|null = null

  real or mock Carbon instance

$timezone : mixed = null

#### setTime()

CarbonInterface.php : 3904

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

`public setTime(int $hour, int $minute[, int $second = 0 ][, int $microseconds = 0 ]) : static`

##### Parameters

$hour : int
$minute : int
$second : int = 0
$microseconds : int = 0

##### Tags

see
  https://php.net/manual/en/datetime.settime.php

##### Return values

static

#### setTimeFrom()

CarbonInterface.php : 3909

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

`public setTimeFrom(DateTimeInterface|string $date) : static`

##### Parameters

$date : DateTimeInterface|string

##### Return values

static

#### setTimeFromTimeString()

CarbonInterface.php : 3914

Set the time by time string.

`public setTimeFromTimeString(string $time) : static`

##### Parameters

$time : string

##### Return values

static

#### setTimestamp()

CarbonInterface.php : 3921

Set the instance's timestamp.

`public setTimestamp(string|int|float $timestamp) : static`

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

##### Parameters

$timestamp : string|int|float

##### Return values

static

#### setTimezone()

CarbonInterface.php : 3926

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

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

##### Parameters

$timeZone : DateTimeZone|string|int

##### Return values

static

#### settings()

CarbonInterface.php : 4010

Set specific options.

`public settings(array<string|int, mixed> $settings) : $this|static`

- strictMode: true|false|null
- monthOverflow: true|false|null
- yearOverflow: true|false|null
- humanDiffOptions: int|null
- toStringFormat: string|Closure|null
- toJsonFormat: string|Closure|null
- locale: string|null
- timezone: \DateTimeZone|string|int|null
- macros: array|null
- genericMacros: array|null

##### Parameters

$settings : array<string|int, mixed>

##### Return values

$this|static

#### setToStringFormat()

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

##### Parameters

$format : string|Closure|null

##### Tags

deprecated

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

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

#### setTranslator()

CarbonInterface.php : 3949

Set the default translator instance to use.

`public static setTranslator(TranslatorInterface $translator) : void`

##### Parameters

$translator : TranslatorInterface

#### setUnit()

CarbonInterface.php : 3957

Set specified unit to new given value.

`public setUnit(string $unit[, Month|int $value = null ]) : static`

##### Parameters

$unit : string

  year, month, day, hour, minute, second or microsecond

$value : Month|int = null

  new value for given unit

##### Return values

static

#### setUnitNoOverflow()

CarbonInterface.php : 3966

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

`public setUnitNoOverflow(string $valueUnit, int $value, string $overflowUnit) : static`

##### Parameters

$valueUnit : string

  unit name to modify

$value : int

  new value for the input unit

$overflowUnit : string

  unit name to not overflow

##### Return values

static

#### setWeekendDays()

CarbonInterface.php : 3991
`public static setWeekendDays(array<string|int, mixed> $days) : void`

##### Parameters

$days : array<string|int, mixed>

##### Tags

deprecated

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

              ```
              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();
              }
              ```

  Set weekend days

#### shiftTimezone()

CarbonInterface.php : 4015

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

`public shiftTimezone(DateTimeZone|string $value) : static`

##### Parameters

$value : DateTimeZone|string

##### Return values

static

#### shouldOverflowMonths()

CarbonInterface.php : 4022

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

`public static shouldOverflowMonths() : bool`

##### Return values

bool

#### shouldOverflowYears()

CarbonInterface.php : 4029

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

`public static shouldOverflowYears() : bool`

##### Return values

bool

#### since()

CarbonInterface.php : 4037
`public since([mixed $other = null ][, mixed $syntax = null ][, mixed $short = false ][, mixed $parts = 1 ][, mixed $options = null ]) : mixed`

##### Parameters

$other : mixed = null
$syntax : mixed = null
$short : mixed = false
$parts : mixed = 1
$options : mixed = null

##### Tags

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

#### singularUnit()

CarbonInterface.php : 4042

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

`public static singularUnit(string $unit) : string`

##### Parameters

$unit : string

##### Return values

string

#### sleep()

CarbonInterface.php : 4044
`public static sleep(int|float $seconds) : void`

##### Parameters

$seconds : int|float

#### startOf()

CarbonInterface.php : 4056

Modify to start of current given unit.

`public startOf(Unit|string $unit, mixed ...$params) : static`

##### Parameters

$unit : Unit|string
$params : mixed

##### Tags

example

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

##### Return values

static

#### startOfCentury()

CarbonInterface.php : 4068

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

`public startOfCentury() : static`

##### Tags

example

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

##### Return values

static

#### startOfDay()

CarbonInterface.php : 4080

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

`public startOfDay() : static`

##### Tags

example

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

##### Return values

static

#### startOfDecade()

CarbonInterface.php : 4092

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

`public startOfDecade() : static`

##### Tags

example

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

##### Return values

static

#### startOfHour()

CarbonInterface.php : 4102

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

`public startOfHour() : static`

##### Tags

example

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

##### Return values

static

#### startOfMillennium()

CarbonInterface.php : 4114

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

`public startOfMillennium() : static`

##### Tags

example

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

##### Return values

static

#### startOfMillisecond()

CarbonInterface.php : 4126

Modify to start of current millisecond, microseconds such as 12345 become 123000

`public startOfMillisecond() : static`

##### Tags

example

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

##### Return values

static

#### startOfMinute()

CarbonInterface.php : 4136

Modify to start of current minute, seconds become 0

`public startOfMinute() : static`

##### Tags

example

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

##### Return values

static

#### startOfMonth()

CarbonInterface.php : 4148

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

`public startOfMonth() : static`

##### Tags

example

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

##### Return values

static

#### startOfQuarter()

CarbonInterface.php : 4160

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

`public startOfQuarter() : static`

##### Tags

example

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

##### Return values

static

#### startOfSecond()

CarbonInterface.php : 4172

Modify to start of current second, microseconds become 0

`public startOfSecond() : static`

##### Tags

example

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

##### Return values

static

#### startOfWeek()

CarbonInterface.php : 4188

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

`public startOfWeek([WeekDay|int|null $weekStartsAt = null ]) : static`

##### Parameters

$weekStartsAt : WeekDay|int|null = null

  optional start allow you to specify the day of week to use to start the week

##### Tags

example

      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";

##### Return values

static

#### startOfYear()

CarbonInterface.php : 4200

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

`public startOfYear() : static`

##### Tags

example

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

##### Return values

static

#### sub()

CarbonInterface.php : 4215

Subtract given units or interval to the current instance.

`public sub(Unit|string|DateInterval|Closure|CarbonConverterInterface $unit[, int|float $value = 1 ][, bool|null $overflow = null ]) : static`

##### Parameters

$unit : Unit|string|DateInterval|Closure|CarbonConverterInterface
$value : int|float = 1
$overflow : bool|null = null

##### Tags

example

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

example

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

example

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

##### Return values

static

#### subRealUnit()

CarbonInterface.php : 4229
`public subRealUnit(string $unit[, int $value = 1 ]) : static`

##### Parameters

$unit : string
$value : int = 1

##### Tags

deprecated

  Prefer to use add subUTCUnit() which more accurately defines what it's doing.

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

##### Return values

static

#### subtract()

CarbonInterface.php : 4267

Subtract given units or interval to the current instance.

`public subtract(string|DateInterval $unit[, int|float $value = 1 ][, bool|null $overflow = null ]) : static`

##### Parameters

$unit : string|DateInterval
$value : int|float = 1
$overflow : bool|null = null

##### Tags

see
  sub()

##### Return values

static

#### subUnit()

CarbonInterface.php : 4245

Subtract given units to the current instance.

`public subUnit(Unit|string $unit[, mixed $value = 1 ][, bool|null $overflow = null ]) : static`

##### Parameters

$unit : Unit|string
$value : mixed = 1
$overflow : bool|null = null

##### Return values

static

#### subUnitNoOverflow()

CarbonInterface.php : 4254

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

`public subUnitNoOverflow(string $valueUnit, int $value, string $overflowUnit) : static`

##### Parameters

$valueUnit : string

  unit name to modify

$value : int

  amount to subtract to the input unit

$overflowUnit : string

  unit name to not overflow

##### Return values

static

#### subUTCUnit()

CarbonInterface.php : 4240

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

`public subUTCUnit(string $unit[, int $value = 1 ]) : static`

##### Parameters

$unit : string
$value : int = 1

##### Return values

static

#### timespan()

CarbonInterface.php : 4275

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

`public timespan([mixed $other = null ][, mixed $timezone = null ]) : string`

##### Parameters

$other : mixed = null
$timezone : mixed = null

##### Return values

string

#### timestamp()

CarbonInterface.php : 4282

Set the instance's timestamp.

`public timestamp(string|int|float $timestamp) : static`

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

##### Parameters

$timestamp : string|int|float

##### Return values

static

#### timezone()

CarbonInterface.php : 4287
`public timezone(DateTimeZone|string|int $value) : static`

##### Parameters

$value : DateTimeZone|string|int

##### Tags

alias

  setTimezone

##### Return values

static

#### to()

CarbonInterface.php : 4337

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.

`public to([Carbon|DateTimeInterface|string|array<string|int, mixed>|null $other = null ][, int|array<string|int, mixed> $syntax = null ][, bool $short = false ][, int $parts = 1 ][, int $options = null ]) : string`

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

##### Parameters

$other : Carbon|DateTimeInterface|string|array<string|int, mixed>|null = null

  if array passed, will be used as parameters array, see $syntax below; if null passed, now will be used as comparison reference; if any other type, it will be converted to date and used as reference.

$syntax : int|array<string|int, mixed> = null

  if array passed, parameters will be extracted from it, the array may contains:

  - 'syntax' entry (see below)
  - 'short' entry (see below)
  - 'parts' entry (see below)
  - 'options' entry (see below)
  - 'join' entry determines how to join multiple parts of the string `- if $join is a string, it's used as a joiner glue` - if $join is a callable/closure, it get the list of string and should return a string `- if $join is an array, the first item will be the default glue, and the second item` will be used instead of the glue for the last item `- if $join is true, it will be guessed from the locale ('list' translation file entry)` - if $join is missing, a space will be used as glue
  - 'other' entry (see above) if int passed, it add modifiers: Possible values:
  - CarbonInterface::DIFF_ABSOLUTE no modifiers
  - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
  - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier Default value: CarbonInterface::DIFF_ABSOLUTE
$short : bool = false

  displays short format of time units

$parts : int = 1

  maximum number of parts to display (default value: 1: single unit)

$options : int = null

  human diff options

##### Return values

string

#### toArray()

CarbonInterface.php : 4347

Get default array representation.

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

##### Tags

example

      var_dump(Carbon::now()->toArray());

##### Return values

array<string|int, mixed>

#### toAtomString()

CarbonInterface.php : 4357

Format the instance as ATOM

`public toAtomString() : string`

##### Tags

example

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

##### Return values

string

#### toCookieString()

CarbonInterface.php : 4367

Format the instance as COOKIE

`public toCookieString() : string`

##### Tags

example

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

##### Return values

string

#### toDate()

CarbonInterface.php : 4379
`public toDate() : DateTime`

##### Tags

alias

  toDateTime

  Return native DateTime PHP object matching the current instance.

example

      var_dump(Carbon::now()->toDate());

##### Return values

DateTime

#### toDateString()

CarbonInterface.php : 4389

Format the instance as date

`public toDateString() : string`

##### Tags

example

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

##### Return values

string

#### toDateTime()

CarbonInterface.php : 4399

Return native DateTime PHP object matching the current instance.

`public toDateTime() : DateTime`

##### Tags

example

      var_dump(Carbon::now()->toDateTime());

##### Return values

DateTime

#### toDateTimeImmutable()

CarbonInterface.php : 4409

Return native toDateTimeImmutable PHP object matching the current instance.

`public toDateTimeImmutable() : DateTimeImmutable`

##### Tags

example

      var_dump(Carbon::now()->toDateTimeImmutable());

##### Return values

DateTimeImmutable

#### toDateTimeLocalString()

CarbonInterface.php : 4421

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

`public toDateTimeLocalString([string $unitPrecision = 'second' ]) : string`

##### Parameters

$unitPrecision : string = 'second'

##### Tags

example

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

##### Return values

string

#### toDateTimeString()

CarbonInterface.php : 4431

Format the instance as date and time

`public toDateTimeString([string $unitPrecision = 'second' ]) : string`

##### Parameters

$unitPrecision : string = 'second'

##### Tags

example

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

##### Return values

string

#### today()

CarbonInterface.php : 4684

Create a Carbon instance for today.

`public static today([DateTimeZone|string|int|null $timezone = null ]) : static`

##### Parameters

$timezone : DateTimeZone|string|int|null = null

##### Return values

static

#### toDayDateTimeString()

CarbonInterface.php : 4441

Format the instance with day, date and time

`public toDayDateTimeString() : string`

##### Tags

example

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

##### Return values

string

#### toFormattedDateString()

CarbonInterface.php : 4451

Format the instance as a readable date

`public toFormattedDateString() : string`

##### Tags

example

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

##### Return values

string

#### toFormattedDayDateString()

CarbonInterface.php : 4461

Format the instance with the day, and a readable date

`public toFormattedDayDateString() : string`

##### Tags

example

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

##### Return values

string

#### toImmutable()

CarbonInterface.php : 4482

Return a immutable copy of the instance.

`public toImmutable() : CarbonImmutable`

##### Return values

CarbonImmutable

#### toIso8601String()

CarbonInterface.php : 4492

Format the instance as ISO8601

`public toIso8601String() : string`

##### Tags

example

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

##### Return values

string

#### toIso8601ZuluString()

CarbonInterface.php : 4502

Convert the instance to UTC and return as Zulu ISO8601

`public toIso8601ZuluString([string $unitPrecision = 'second' ]) : string`

##### Parameters

$unitPrecision : string = 'second'

##### Tags

example

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

##### Return values

string

#### toISOString()

CarbonInterface.php : 4475

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

`public toISOString([bool $keepOffset = false ]) : string|null`

##### Parameters

$keepOffset : bool = false

  Pass true to keep the date offset. Else forced to UTC.

##### Tags

example

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

##### Return values

string|null

#### toJSON()

CarbonInterface.php : 4512

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

`public toJSON() : string|null`

##### Tags

example

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

##### Return values

string|null

#### tomorrow()

CarbonInterface.php : 4689

Create a Carbon instance for tomorrow.

`public static tomorrow([DateTimeZone|string|int|null $timezone = null ]) : static`

##### Parameters

$timezone : DateTimeZone|string|int|null = null

##### Return values

static

#### toMutable()

CarbonInterface.php : 4519

Return a mutable copy of the instance.

`public toMutable() : Carbon`

##### Return values

Carbon

#### toNow()

CarbonInterface.php : 4549

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

`public toNow([int|array<string|int, mixed> $syntax = null ][, bool $short = false ][, int $parts = 1 ][, int $options = null ]) : string`

##### Parameters

$syntax : int|array<string|int, mixed> = null

  if array passed, parameters will be extracted from it, the array may contains:

  - 'syntax' entry (see below)
  - 'short' entry (see below)
  - 'parts' entry (see below)
  - 'options' entry (see below)
  - 'join' entry determines how to join multiple parts of the string `- if $join is a string, it's used as a joiner glue` - if $join is a callable/closure, it get the list of string and should return a string `- if $join is an array, the first item will be the default glue, and the second item` will be used instead of the glue for the last item `- if $join is true, it will be guessed from the locale ('list' translation file entry)` - if $join is missing, a space will be used as glue if int passed, it add modifiers: Possible values:
  - CarbonInterface::DIFF_ABSOLUTE no modifiers
  - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
  - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier Default value: CarbonInterface::DIFF_ABSOLUTE
$short : bool = false

  displays short format of time units

$parts : int = 1

  maximum number of parts to display (default value: 1: single part)

$options : int = null

  human diff options

##### Return values

string

#### toObject()

CarbonInterface.php : 4559

Get default object representation.

`public toObject() : object`

##### Tags

example

      var_dump(Carbon::now()->toObject());

##### Return values

object

#### toPeriod()

CarbonInterface.php : 4568

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

`public toPeriod([DateTimeInterface|Carbon|CarbonImmutable|int|null $end = null ][, int|DateInterval|string|null $interval = null ][, string|null $unit = null ]) : CarbonPeriod`

##### Parameters

$end : DateTimeInterface|Carbon|CarbonImmutable|int|null = null

  period end date or recurrences count if int

$interval : int|DateInterval|string|null = null

  period default interval or number of the given $unit

$unit : string|null = null

  if specified, $interval must be an integer

##### Return values

CarbonPeriod

#### toRfc1036String()

CarbonInterface.php : 4578

Format the instance as RFC1036

`public toRfc1036String() : string`

##### Tags

example

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

##### Return values

string

#### toRfc1123String()

CarbonInterface.php : 4588

Format the instance as RFC1123

`public toRfc1123String() : string`

##### Tags

example

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

##### Return values

string

#### toRfc2822String()

CarbonInterface.php : 4598

Format the instance as RFC2822

`public toRfc2822String() : string`

##### Tags

example

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

##### Return values

string

#### toRfc3339String()

CarbonInterface.php : 4609

Format the instance as RFC3339.

`public toRfc3339String([bool $extended = false ]) : string`

##### Parameters

$extended : bool = false

##### Tags

example

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

##### Return values

string

#### toRfc7231String()

CarbonInterface.php : 4619

Format the instance as RFC7231

`public toRfc7231String() : string`

##### Tags

example

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

##### Return values

string

#### toRfc822String()

CarbonInterface.php : 4629

Format the instance as RFC822

`public toRfc822String() : string`

##### Tags

example

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

##### Return values

string

#### toRfc850String()

CarbonInterface.php : 4639

Format the instance as RFC850

`public toRfc850String() : string`

##### Tags

example

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

##### Return values

string

#### toRssString()

CarbonInterface.php : 4649

Format the instance as RSS

`public toRssString() : string`

##### Tags

example

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

##### Return values

string

#### toString()

CarbonInterface.php : 4659

Returns english human-readable complete date string.

`public toString() : string`

##### Tags

example

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

##### Return values

string

#### toTimeString()

CarbonInterface.php : 4669

Format the instance as time

`public toTimeString([string $unitPrecision = 'second' ]) : string`

##### Parameters

$unitPrecision : string = 'second'

##### Tags

example

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

##### Return values

string

#### toW3cString()

CarbonInterface.php : 4679

Format the instance as W3C

`public toW3cString() : string`

##### Tags

example

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

##### Return values

string

#### translate()

CarbonInterface.php : 4702

Translate using translation string or callback available.

`public translate(string $key[, array<string|int, mixed> $parameters = [] ][, string|int|float|null $number = null ][, TranslatorInterface|null $translator = null ][, bool $altNumbers = false ]) : string`

##### Parameters

$key : string

  key to find

$parameters : array<string|int, mixed> = []

  replacement parameters

$number : string|int|float|null = null

  number if plural

$translator : TranslatorInterface|null = null

  an optional translator to use

$altNumbers : bool = false

  pass true to use alternative numbers

##### Return values

string

#### translatedFormat()

CarbonInterface.php : 4757

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

`public translatedFormat(string $format) : string`

##### Parameters

$format : string

##### Return values

string

#### translateNumber()

CarbonInterface.php : 4711

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

`public translateNumber(int $number) : string`

##### Parameters

$number : int

##### Return values

string

#### translateTimeString()

CarbonInterface.php : 4729

Translate a time string from a locale to an other.

`public static translateTimeString(string $timeString[, string|null $from = null ][, string|null $to = null ][, int $mode = self::TRANSLATE_ALL ]) : string`

##### Parameters

$timeString : string

  date/time/duration string to translate (may also contain English)

$from : string|null = null

  input locale of the $timeString parameter (`Carbon::getLocale()` by default)

$to : string|null = null

  output locale of the result returned (`"en"` by default)

$mode : int = self::TRANSLATE_ALL

  specify what to translate with options:

  - self::TRANSLATE_ALL (default)
  - CarbonInterface::TRANSLATE_MONTHS
  - CarbonInterface::TRANSLATE_DAYS
  - CarbonInterface::TRANSLATE_UNITS
  - CarbonInterface::TRANSLATE_MERIDIEM You can use pipe to group: CarbonInterface::TRANSLATE_MONTHS | CarbonInterface::TRANSLATE_DAYS

##### Return values

string

#### translateTimeStringTo()

CarbonInterface.php : 4739

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

`public translateTimeStringTo(string $timeString[, string|null $to = null ]) : string`

##### Parameters

$timeString : string

  time string to translate

$to : string|null = null

  output locale of the result returned ("en" by default)

##### Return values

string

#### translateWith()

CarbonInterface.php : 4751

Translate using translation string or callback available.

`public static translateWith(TranslatorInterface $translator, string $key[, array<string|int, mixed> $parameters = [] ][, int|float|null $number = null ]) : string`

##### Parameters

$translator : TranslatorInterface

  an optional translator to use

$key : string

  key to find

$parameters : array<string|int, mixed> = []

  replacement parameters

$number : int|float|null = null

  number if plural

##### Return values

string

#### tz()

CarbonInterface.php : 4762

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

`public tz([DateTimeZone|string|int|null $value = null ]) : static|string`

##### Parameters

$value : DateTimeZone|string|int|null = null

##### Return values

static|string

#### unix()

CarbonInterface.php : 4771
`public unix() : int`

##### Tags

alias

  getTimestamp

  Returns the UNIX timestamp for the current date.

##### Return values

int

#### until()

CarbonInterface.php : 4807
`public until([Carbon|DateTimeInterface|string|array<string|int, mixed>|null $other = null ][, int|array<string|int, mixed> $syntax = null ][, bool $short = false ][, int $parts = 1 ][, int $options = null ]) : string`

##### Parameters

$other : Carbon|DateTimeInterface|string|array<string|int, mixed>|null = null

  if array passed, will be used as parameters array, see $syntax below; if null passed, now will be used as comparison reference; if any other type, it will be converted to date and used as reference.

$syntax : int|array<string|int, mixed> = null

  if array passed, parameters will be extracted from it, the array may contains:

  - 'syntax' entry (see below)
  - 'short' entry (see below)
  - 'parts' entry (see below)
  - 'options' entry (see below)
  - 'join' entry determines how to join multiple parts of the string `- if $join is a string, it's used as a joiner glue` - if $join is a callable/closure, it get the list of string and should return a string `- if $join is an array, the first item will be the default glue, and the second item` will be used instead of the glue for the last item `- if $join is true, it will be guessed from the locale ('list' translation file entry)` - if $join is missing, a space will be used as glue
  - 'other' entry (see above) if int passed, it add modifiers: Possible values:
  - CarbonInterface::DIFF_ABSOLUTE no modifiers
  - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier
  - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier Default value: CarbonInterface::DIFF_ABSOLUTE
$short : bool = false

  displays short format of time units

$parts : int = 1

  maximum number of parts to display (default value: 1: single unit)

$options : int = null

  human diff options

##### Tags

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.

##### Return values

string

#### useMonthsOverflow()

CarbonInterface.php : 4822
`public static useMonthsOverflow([bool $monthsOverflow = true ]) : void`

##### Parameters

$monthsOverflow : bool = true

##### Tags

deprecated

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

see
  settings

  Indicates if months should be calculated with overflow.

#### useStrictMode()

CarbonInterface.php : 4833
`public static useStrictMode([bool $strictModeEnabled = true ]) : void`

##### Parameters

$strictModeEnabled : bool = true

##### Tags

deprecated

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

see
  settings

  Enable the strict mode (or disable with passing false).

#### useYearsOverflow()

CarbonInterface.php : 4848
`public static useYearsOverflow([bool $yearsOverflow = true ]) : void`

##### Parameters

$yearsOverflow : bool = true

##### Tags

deprecated

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

see
  settings

  Indicates if years should be calculated with overflow.

#### utc()

CarbonInterface.php : 4853

Set the instance's timezone to UTC.

`public utc() : static`

##### Return values

static

#### utcOffset()

CarbonInterface.php : 4858

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

`public utcOffset([int|null $minuteOffset = null ]) : static|int`

##### Parameters

$minuteOffset : int|null = null

##### Return values

static|int

#### valueOf()

CarbonInterface.php : 4865

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

`public valueOf() : float`

##### Return values

float

#### week()

CarbonInterface.php : 4878

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

`public week([int|null $week = null ][, int|null $dayOfWeek = null ][, int|null $dayOfYear = null ]) : int|static`

##### Parameters

$week : int|null = null
$dayOfWeek : int|null = null
$dayOfYear : int|null = null

##### Return values

int|static

#### weekday()

CarbonInterface.php : 4898

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

`public weekday([WeekDay|int|null $value = null ]) : static|int`

##### Parameters

$value : WeekDay|int|null = null

  new value for weekday if using as setter.

##### Return values

static|int

#### weeksInYear()

CarbonInterface.php : 4910

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

`public weeksInYear([int|null $dayOfWeek = null ][, int|null $dayOfYear = null ]) : int`

##### Parameters

$dayOfWeek : int|null = null

  first date of week from 0 (Sunday) to 6 (Saturday)

$dayOfYear : int|null = null

  first day of year included in the week #1

##### Return values

int

#### weekYear()

CarbonInterface.php : 4891

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

`public weekYear([int|null $year = null ][, int|null $dayOfWeek = null ][, int|null $dayOfYear = null ]) : int|static`

##### Parameters

$year : int|null = null

  if null, act as a getter, if not null, set the year and return current instance.

$dayOfWeek : int|null = null

  first date of week from 0 (Sunday) to 6 (Saturday)

$dayOfYear : int|null = null

  first day of year included in the week #1

##### Return values

int|static

#### withTestNow()

CarbonInterface.php : 4926

Temporarily sets a static date to be used within the callback.

`public static withTestNow(DateTimeInterface|Closure|static|string|false|null $testNow, callable $callback) : T`

Using setTestNow to set the date, executing the callback, then clearing the test instance.

/!\ Use this method for unit tests only.

##### Parameters

$testNow : DateTimeInterface|Closure|static|string|false|null

  real or mock Carbon instance

$callback : callable

##### Tags

template

  T

##### Return values

T

#### yesterday()

CarbonInterface.php : 4931

Create a Carbon instance for yesterday.

`public static yesterday([DateTimeZone|string|int|null $timezone = null ]) : static`

##### Parameters

$timezone : DateTimeZone|string|int|null = null

##### Return values

static

## Search results