$date * * @return bool */ public function lessThan($date) : bool; /** * Determines if the instance is less (before) or equal to another * * @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 * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @return bool */ public function lessThanOrEqualTo($date) : bool; /** * Get/set the locale for the current instance. * * @param string|null $locale * @param string ...$fallbackLocales * * @return $this|string */ public function locale(?string $locale = null, ...$fallbackLocales); /** * Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow). * Support is considered enabled if the 3 words are translated in the given locale. * * @param string $locale locale ex. en * * @return bool */ public static function localeHasDiffOneDayWords($locale); /** * Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after). * Support is considered enabled if the 4 sentences are translated in the given locale. * * @param string $locale locale ex. en * * @return bool */ public static function localeHasDiffSyntax($locale); /** * Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow). * Support is considered enabled if the 2 words are translated in the given locale. * * @param string $locale locale ex. en * * @return bool */ public static function localeHasDiffTwoDayWords($locale); /** * Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X). * Support is considered enabled if the 4 sentences are translated in the given locale. * * @param string $locale locale ex. en * * @return bool */ public static function localeHasPeriodSyntax($locale); /** * Returns true if the given locale is internally supported and has short-units support. * Support is considered enabled if either year, day or hour has a short variant translated. * * @param string $locale locale ex. en * * @return bool */ public static function localeHasShortUnits($locale); /** * Determines if the instance is less (before) than another * * @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 * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see lessThan() * * @return bool */ public function lt($date) : bool; /** * Determines if the instance is less (before) or equal to another * * @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 * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see lessThanOrEqualTo() * * @return bool */ public function lte($date) : bool; /** * Register a custom macro. * * @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(); * ``` * * @param string $name * @param object|callable $macro * * @return void */ public static function macro($name, $macro); /** * Make a Carbon instance from given variable if possible. * * Always return a new instance. Parse only strings and only these likely to be dates (skip intervals * and recurrences). Throw an exception for invalid format, but otherwise return null. * * @param mixed $var * * @throws InvalidFormatException * * @return static|null */ public static function make($var); /** * Get the maximum instance between a given instance (default now) and the current instance. * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @return static */ public function max($date = null); /** * Create a Carbon instance for the greatest supported date. * * @return static */ public static function maxValue(); /** * Get the maximum instance between a given instance (default now) and the current instance. * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see max() * * @return static */ public function maximum($date = null); /** * Return the meridiem of the current time in the current locale. * * @param bool $isLower if true, returns lowercase variant if available in the current locale. * * @return string */ public function meridiem(bool $isLower = \false) : string; /** * Modify to midday, default to self::$midDayAt * * @return static */ public function midDay(); /** * Get the minimum instance between a given instance (default now) and the current instance. * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @return static */ public function min($date = null); /** * Create a Carbon instance for the lowest supported date. * * @return static */ public static function minValue(); /** * Get the minimum instance between a given instance (default now) and the current instance. * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see min() * * @return static */ public function minimum($date = null); /** * Mix another object into the class. * * @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"; * ``` * * @param object|string $mixin * * @throws ReflectionException * * @return void */ public static function mixin($mixin); /** * Calls \DateTime::modify if mutable or \DateTimeImmutable::modify else. * * @see https://php.net/manual/en/datetime.modify.php * * @return static|false */ #[\ReturnTypeWillChange] public function modify($modify); /** * Determines if the instance is not equal to another * * @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 * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see notEqualTo() * * @return bool */ public function ne($date) : bool; /** * 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. * * @param string|int|null $modifier * * @return static|false */ public function next($modifier = null); /** * Go forward to the next weekday. * * @return static */ public function nextWeekday(); /** * Go forward to the next weekend day. * * @return static */ public function nextWeekendDay(); /** * Determines if the instance is not equal to another * * @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 * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @return bool */ public function notEqualTo($date) : bool; /** * Get a Carbon instance for the current date and time. * * @param DateTimeZone|string|null $tz * * @return static */ public static function now($tz = null); /** * Returns a present instance in the same timezone. * * @return static */ public function nowWithSameTz(); /** * Modify to the given occurrence of a given day of the week * in the current month. If the calculated occurrence is outside the scope * of the current month, then return false and no modifications are made. * Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $nth * @param int $dayOfWeek * * @return mixed */ public function nthOfMonth($nth, $dayOfWeek); /** * Modify to the given occurrence of a given day of the week * in the current quarter. If the calculated occurrence is outside the scope * of the current quarter, then return false and no modifications are made. * Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $nth * @param int $dayOfWeek * * @return mixed */ public function nthOfQuarter($nth, $dayOfWeek); /** * Modify to the given occurrence of a given day of the week * in the current year. If the calculated occurrence is outside the scope * of the current year, then return false and no modifications are made. * Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $nth * @param int $dayOfWeek * * @return mixed */ public function nthOfYear($nth, $dayOfWeek); /** * Return a property with its ordinal. * * @param string $key * @param string|null $period * * @return string */ public function ordinal(string $key, ?string $period = null) : string; /** * Create a carbon instance from a string. * * This is an alias for the constructor that allows better fluent syntax * as it allows you to do Carbon::parse('Monday next week')->fn() rather * than (new Carbon('Monday next week'))->fn(). * * @param string|DateTimeInterface|null $time * @param DateTimeZone|string|null $tz * * @throws InvalidFormatException * * @return static */ public static function parse($time = null, $tz = null); /** * Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.). * * @param string $time date/time string in the given language (may also contain English). * @param string|null $locale if locale is null or not specified, current global locale will be * used instead. * @param DateTimeZone|string|null $tz optional timezone for the new instance. * * @throws InvalidFormatException * * @return static */ public static function parseFromLocale($time, $locale = null, $tz = null); /** * Returns standardized plural of a given singular/plural unit name (in English). * * @param string $unit * * @return string */ public static function pluralUnit(string $unit) : string; /** * 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. * * @param string|int|null $modifier * * @return static|false */ public function previous($modifier = null); /** * Go backward to the previous weekday. * * @return static */ public function previousWeekday(); /** * Go backward to the previous weekend day. * * @return static */ public function previousWeekendDay(); /** * Create a iterable CarbonPeriod object from current date to a given end date (and optional interval). * * @param \DateTimeInterface|Carbon|CarbonImmutable|null $end period end date * @param int|\DateInterval|string|null $interval period default interval or number of the given $unit * @param string|null $unit if specified, $interval must be an integer * * @return CarbonPeriod */ public function range($end = null, $interval = null, $unit = null); /** * Call native PHP DateTime/DateTimeImmutable add() method. * * @param DateInterval $interval * * @return static */ public function rawAdd(DateInterval $interval); /** * Create a Carbon instance from a specific format. * * @param string $format Datetime format * @param string $time * @param DateTimeZone|string|false|null $tz * * @throws InvalidFormatException * * @return static|false */ public static function rawCreateFromFormat($format, $time, $tz = null); /** * @see https://php.net/manual/en/datetime.format.php * * @param string $format * * @return string */ public function rawFormat($format); /** * Create a carbon instance from a string. * * This is an alias for the constructor that allows better fluent syntax * as it allows you to do Carbon::parse('Monday next week')->fn() rather * than (new Carbon('Monday next week'))->fn(). * * @param string|DateTimeInterface|null $time * @param DateTimeZone|string|null $tz * * @throws InvalidFormatException * * @return static */ public static function rawParse($time = null, $tz = null); /** * Call native PHP DateTime/DateTimeImmutable sub() method. * * @param DateInterval $interval * * @return static */ public function rawSub(DateInterval $interval); /** * Remove all macros and generic macros. */ public static function resetMacros(); /** * @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. * * @return void */ public static function resetMonthsOverflow(); /** * Reset the format used to the default when type juggling a Carbon instance to a string * * @return void */ public static function resetToStringFormat(); /** * @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. * * @return void */ public static function resetYearsOverflow(); /** * Round the current instance second with given precision if specified. * * @param float|int|string|\DateInterval|null $precision * @param string $function * * @return CarbonInterface */ public function round($precision = 1, $function = 'round'); /** * Round the current instance at the given unit with given precision if specified and the given function. * * @param string $unit * @param float|int $precision * @param string $function * * @return CarbonInterface */ public function roundUnit($unit, $precision = 1, $function = 'round'); /** * Round the current instance week. * * @param int $weekStartsAt optional start allow you to specify the day of week to use to start the week * * @return CarbonInterface */ public function roundWeek($weekStartsAt = null); /** * The number of seconds since midnight. * * @return int */ public function secondsSinceMidnight(); /** * The number of seconds until 23:59:59. * * @return int */ public function secondsUntilEndOfDay(); /** * Return a serialized string of the instance. * * @return string */ public function serialize(); /** * @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. * * @param callable $callback * * @return void */ public static function serializeUsing($callback); /** * Set a part of the Carbon object * * @param string|array $name * @param string|int|DateTimeZone $value * * @throws ImmutableException|UnknownSetterException * * @return $this */ public function set($name, $value = null); /** * Set the date with gregorian year, month and day numbers. * * @see https://php.net/manual/en/datetime.setdate.php * * @param int $year * @param int $month * @param int $day * * @return static */ #[\ReturnTypeWillChange] public function setDate($year, $month, $day); /** * Set the year, month, and date for this instance to that of the passed instance. * * @param Carbon|DateTimeInterface $date now if null * * @return static */ public function setDateFrom($date = null); /** * Set the date and time all together. * * @param int $year * @param int $month * @param int $day * @param int $hour * @param int $minute * @param int $second * @param int $microseconds * * @return static */ public function setDateTime($year, $month, $day, $hour, $minute, $second = 0, $microseconds = 0); /** * Set the date and time for this instance to that of the passed instance. * * @param Carbon|DateTimeInterface $date * * @return static */ public function setDateTimeFrom($date = null); /** * 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. * * @param int $numberOfDays number of days to add after the start of the current week * @param int|null $weekStartsAt 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 static */ public function setDaysFromStartOfWeek(int $numberOfDays, ?int $weekStartsAt = null); /** * Set the fallback locale. * * @see https://symfony.com/doc/current/components/translation.html#fallback-locales * * @param string $locale */ public static function setFallbackLocale($locale); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather use the ->settings() method. * @see settings * * @param int $humanDiffOptions */ public static function setHumanDiffOptions($humanDiffOptions); /** * Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates. * * @see https://php.net/manual/en/datetime.setisodate.php * * @param int $year * @param int $week * @param int $day * * @return static */ #[\ReturnTypeWillChange] public function setISODate($year, $week, $day = 1); /** * Set the translator for the current instance. * * @param \Symfony\Component\Translation\TranslatorInterface $translator * * @return $this */ public function setLocalTranslator(TranslatorInterface $translator); /** * Set the current translator locale and indicate if the source locale file exists. * Pass 'auto' as locale to use closest language from the current LC_TIME locale. * * @param string $locale locale ex. en * * @return bool */ public static function setLocale($locale); /** * @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 * * @param int $hour midday hour * * @return void */ public static function setMidDayAt($hour); /** * Set a Carbon instance (real or mock) to be returned when a "now" * instance is created. The provided instance will be returned * specifically under the following conditions: * - A call to the static now() method, ex. Carbon::now() * - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null) * - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now') * - When a string containing the desired time is passed to Carbon::parse(). * * Note the timezone parameter was left out of the examples above and * has no affect as the mock value will be returned regardless of its value. * * Only the moment is mocked with setTestNow(), the timezone will still be the one passed * as parameter of date_default_timezone_get() as a fallback (see setTestNowAndTimezone()). * * To clear the test instance call this method using the default * parameter of null. * * /!\ Use this method for unit tests only. * * @param DateTimeInterface|Closure|static|string|false|null $testNow real or mock Carbon instance */ public static function setTestNow($testNow = null); /** * Set a Carbon instance (real or mock) to be returned when a "now" * instance is created. The provided instance will be returned * specifically under the following conditions: * - A call to the static now() method, ex. Carbon::now() * - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null) * - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now') * - When a string containing the desired time is passed to Carbon::parse(). * * 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. * * @param DateTimeInterface|Closure|static|string|false|null $testNow real or mock Carbon instance */ public static function setTestNowAndTimezone($testNow = null, $tz = null); /** * Resets the current time of the DateTime object to a different time. * * @see https://php.net/manual/en/datetime.settime.php * * @param int $hour * @param int $minute * @param int $second * @param int $microseconds * * @return static */ #[\ReturnTypeWillChange] public function setTime($hour, $minute, $second = 0, $microseconds = 0); /** * Set the hour, minute, second and microseconds for this instance to that of the passed instance. * * @param Carbon|DateTimeInterface $date now if null * * @return static */ public function setTimeFrom($date = null); /** * Set the time by time string. * * @param string $time * * @return static */ public function setTimeFromTimeString($time); /** * Set the instance's timestamp. * * Timestamp input can be given as int, float or a string containing one or more numbers. * * @param float|int|string $unixTimestamp * * @return static */ #[\ReturnTypeWillChange] public function setTimestamp($unixTimestamp); /** * Set the instance's timezone from a string or object. * * @param DateTimeZone|string $value * * @return static */ #[\ReturnTypeWillChange] public function setTimezone($value); /** * @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. * * @param string|Closure|null $format * * @return void */ public static function setToStringFormat($format); /** * Set the default translator instance to use. * * @param \Symfony\Component\Translation\TranslatorInterface $translator * * @return void */ public static function setTranslator(TranslatorInterface $translator); /** * Set specified unit to new given value. * * @param string $unit year, month, day, hour, minute, second or microsecond * @param int $value new value for given unit * * @return static */ public function setUnit($unit, $value = null); /** * Set any unit to a new value without overflowing current other unit given. * * @param string $valueUnit unit name to modify * @param int $value new value for the input unit * @param string $overflowUnit unit name to not overflow * * @return static */ public function setUnitNoOverflow($valueUnit, $value, $overflowUnit); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather use UTF-8 language packages on every machine. * * Set if UTF8 will be used for localized date/time. * * @param bool $utf8 */ public static function setUtf8($utf8); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * Use $weekStartsAt optional parameter instead when using startOfWeek, floorWeek, ceilWeek * or roundWeek method. You can also use the 'first_day_of_week' locale setting to change the * start of week according to current locale selected and implicitly the end of week. * * Set the last day of week * * @param int|string $day week end day (or 'auto' to get the day before the first day of week * from Carbon::getLocale() culture). * * @return void */ public static function setWeekEndsAt($day); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * Use $weekEndsAt optional parameter instead when using endOfWeek method. You can also use the * 'first_day_of_week' locale setting to change the start of week according to current locale * selected and implicitly the end of week. * * Set the first day of week * * @param int|string $day week start day (or 'auto' to get the first day of week from Carbon::getLocale() culture). * * @return void */ public static function setWeekStartsAt($day); /** * @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 * * @param array $days * * @return void */ public static function setWeekendDays($days); /** * Set specific options. * - strictMode: true|false|null * - monthOverflow: true|false|null * - yearOverflow: true|false|null * - humanDiffOptions: int|null * - toStringFormat: string|Closure|null * - toJsonFormat: string|Closure|null * - locale: string|null * - timezone: \DateTimeZone|string|int|null * - macros: array|null * - genericMacros: array|null * * @param array $settings * * @return $this|static */ public function settings(array $settings); /** * Set the instance's timezone from a string or object and add/subtract the offset difference. * * @param DateTimeZone|string $value * * @return static */ public function shiftTimezone($value); /** * Get the month overflow global behavior (can be overridden in specific instances). * * @return bool */ public static function shouldOverflowMonths(); /** * Get the month overflow global behavior (can be overridden in specific instances). * * @return bool */ public static function shouldOverflowYears(); /** * @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). */ public function since($other = null, $syntax = null, $short = \false, $parts = 1, $options = null); /** * Returns standardized singular of a given singular/plural unit name (in English). * * @param string $unit * * @return string */ public static function singularUnit(string $unit) : string; /** * Modify to start of current given unit. * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16.334455') * ->startOf('month') * ->endOf('week', Carbon::FRIDAY); * ``` * * @param string $unit * @param array $params * * @return static */ public function startOf($unit, ...$params); /** * Resets the date to the first day of the century and the time to 00:00:00 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfCentury(); * ``` * * @return static */ public function startOfCentury(); /** * Resets the time to 00:00:00 start of day * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfDay(); * ``` * * @return static */ public function startOfDay(); /** * Resets the date to the first day of the decade and the time to 00:00:00 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfDecade(); * ``` * * @return static */ public function startOfDecade(); /** * Modify to start of current hour, minutes and seconds become 0 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfHour(); * ``` * * @return static */ public function startOfHour(); /** * Resets the date to the first day of the millennium and the time to 00:00:00 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfMillennium(); * ``` * * @return static */ public function startOfMillennium(); /** * Modify to start of current minute, seconds become 0 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfMinute(); * ``` * * @return static */ public function startOfMinute(); /** * Resets the date to the first day of the month and the time to 00:00:00 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfMonth(); * ``` * * @return static */ public function startOfMonth(); /** * Resets the date to the first day of the quarter and the time to 00:00:00 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfQuarter(); * ``` * * @return static */ public function startOfQuarter(); /** * Modify to start of current second, microseconds become 0 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16.334455') * ->startOfSecond() * ->format('H:i:s.u'); * ``` * * @return static */ public function startOfSecond(); /** * Resets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00 * * @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"; * ``` * * @param int $weekStartsAt optional start allow you to specify the day of week to use to start the week * * @return static */ public function startOfWeek($weekStartsAt = null); /** * Resets the date to the first day of the year and the time to 00:00:00 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfYear(); * ``` * * @return static */ public function startOfYear(); /** * Subtract given units or interval to the current instance. * * @example $date->sub('hour', 3) * @example $date->sub(15, 'days') * @example $date->sub(CarbonInterval::days(4)) * * @param string|DateInterval|Closure|CarbonConverterInterface $unit * @param int $value * @param bool|null $overflow * * @return static */ #[\ReturnTypeWillChange] public function sub($unit, $value = 1, $overflow = null); public function subRealUnit($unit, $value = 1); /** * Subtract given units to the current instance. * * @param string $unit * @param int $value * @param bool|null $overflow * * @return static */ public function subUnit($unit, $value = 1, $overflow = null); /** * Subtract any unit to a new value without overflowing current other unit given. * * @param string $valueUnit unit name to modify * @param int $value amount to subtract to the input unit * @param string $overflowUnit unit name to not overflow * * @return static */ public function subUnitNoOverflow($valueUnit, $value, $overflowUnit); /** * Subtract given units or interval to the current instance. * * @see sub() * * @param string|DateInterval $unit * @param int $value * @param bool|null $overflow * * @return static */ public function subtract($unit, $value = 1, $overflow = null); /** * 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 string */ public function timespan($other = null, $timezone = null); /** * Set the instance's timestamp. * * Timestamp input can be given as int, float or a string containing one or more numbers. * * @param float|int|string $unixTimestamp * * @return static */ public function timestamp($unixTimestamp); /** * @alias setTimezone * * @param DateTimeZone|string $value * * @return static */ public function timezone($value); /** * Get the difference in a human readable format in the current locale from an other * instance given (or now if null given) to current instance. * * When comparing a value in the past to default now: * 1 hour from now * 5 months from now * * When comparing a value in the future to default now: * 1 hour ago * 5 months ago * * When comparing a value in the past to another value: * 1 hour after * 5 months after * * When comparing a value in the future to another value: * 1 hour before * 5 months before * * @param Carbon|\DateTimeInterface|string|array|null $other 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. * @param int|array $syntax 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 * @param bool $short displays short format of time units * @param int $parts maximum number of parts to display (default value: 1: single unit) * @param int $options human diff options * * @return string */ public function to($other = null, $syntax = null, $short = \false, $parts = 1, $options = null); /** * Get default array representation. * * @example * ``` * var_dump(Carbon::now()->toArray()); * ``` * * @return array */ public function toArray(); /** * Format the instance as ATOM * * @example * ``` * echo Carbon::now()->toAtomString(); * ``` * * @return string */ public function toAtomString(); /** * Format the instance as COOKIE * * @example * ``` * echo Carbon::now()->toCookieString(); * ``` * * @return string */ public function toCookieString(); /** * @alias toDateTime * * Return native DateTime PHP object matching the current instance. * * @example * ``` * var_dump(Carbon::now()->toDate()); * ``` * * @return DateTime */ public function toDate(); /** * Format the instance as date * * @example * ``` * echo Carbon::now()->toDateString(); * ``` * * @return string */ public function toDateString(); /** * Return native DateTime PHP object matching the current instance. * * @example * ``` * var_dump(Carbon::now()->toDateTime()); * ``` * * @return DateTime */ public function toDateTime(); /** * Return native toDateTimeImmutable PHP object matching the current instance. * * @example * ``` * var_dump(Carbon::now()->toDateTimeImmutable()); * ``` * * @return DateTimeImmutable */ public function toDateTimeImmutable(); /** * Format the instance as date and time T-separated with no timezone * * @example * ``` * echo Carbon::now()->toDateTimeLocalString(); * echo "\n"; * echo Carbon::now()->toDateTimeLocalString('minute'); // You can specify precision among: minute, second, millisecond and microsecond * ``` * * @param string $unitPrecision * * @return string */ public function toDateTimeLocalString($unitPrecision = 'second'); /** * Format the instance as date and time * * @example * ``` * echo Carbon::now()->toDateTimeString(); * ``` * * @param string $unitPrecision * * @return string */ public function toDateTimeString($unitPrecision = 'second'); /** * Format the instance with day, date and time * * @example * ``` * echo Carbon::now()->toDayDateTimeString(); * ``` * * @return string */ public function toDayDateTimeString(); /** * Format the instance as a readable date * * @example * ``` * echo Carbon::now()->toFormattedDateString(); * ``` * * @return string */ public function toFormattedDateString(); /** * Format the instance with the day, and a readable date * * @example * ``` * echo Carbon::now()->toFormattedDayDateString(); * ``` * * @return string */ public function toFormattedDayDateString() : string; /** * Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z, if $keepOffset truthy, offset will be kept: * 1977-04-22T01:00:00-05:00). * * @example * ``` * echo Carbon::now('America/Toronto')->toISOString() . "\n"; * echo Carbon::now('America/Toronto')->toISOString(true) . "\n"; * ``` * * @param bool $keepOffset Pass true to keep the date offset. Else forced to UTC. * * @return null|string */ public function toISOString($keepOffset = \false); /** * Return a immutable copy of the instance. * * @return CarbonImmutable */ public function toImmutable(); /** * Format the instance as ISO8601 * * @example * ``` * echo Carbon::now()->toIso8601String(); * ``` * * @return string */ public function toIso8601String(); /** * Convert the instance to UTC and return as Zulu ISO8601 * * @example * ``` * echo Carbon::now()->toIso8601ZuluString(); * ``` * * @param string $unitPrecision * * @return string */ public function toIso8601ZuluString($unitPrecision = 'second'); /** * Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z) with UTC timezone. * * @example * ``` * echo Carbon::now('America/Toronto')->toJSON(); * ``` * * @return null|string */ public function toJSON(); /** * Return a mutable copy of the instance. * * @return Carbon */ public function toMutable(); /** * Get the difference in a human readable format in the current locale from an other * instance given to now * * @param int|array $syntax 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 * @param bool $short displays short format of time units * @param int $parts maximum number of parts to display (default value: 1: single part) * @param int $options human diff options * * @return string */ public function toNow($syntax = null, $short = \false, $parts = 1, $options = null); /** * Get default object representation. * * @example * ``` * var_dump(Carbon::now()->toObject()); * ``` * * @return object */ public function toObject(); /** * Create a iterable CarbonPeriod object from current date to a given end date (and optional interval). * * @param \DateTimeInterface|Carbon|CarbonImmutable|int|null $end period end date or recurrences count if int * @param int|\DateInterval|string|null $interval period default interval or number of the given $unit * @param string|null $unit if specified, $interval must be an integer * * @return CarbonPeriod */ public function toPeriod($end = null, $interval = null, $unit = null); /** * Format the instance as RFC1036 * * @example * ``` * echo Carbon::now()->toRfc1036String(); * ``` * * @return string */ public function toRfc1036String(); /** * Format the instance as RFC1123 * * @example * ``` * echo Carbon::now()->toRfc1123String(); * ``` * * @return string */ public function toRfc1123String(); /** * Format the instance as RFC2822 * * @example * ``` * echo Carbon::now()->toRfc2822String(); * ``` * * @return string */ public function toRfc2822String(); /** * Format the instance as RFC3339 * * @param bool $extended * * @example * ``` * echo Carbon::now()->toRfc3339String() . "\n"; * echo Carbon::now()->toRfc3339String(true) . "\n"; * ``` * * @return string */ public function toRfc3339String($extended = \false); /** * Format the instance as RFC7231 * * @example * ``` * echo Carbon::now()->toRfc7231String(); * ``` * * @return string */ public function toRfc7231String(); /** * Format the instance as RFC822 * * @example * ``` * echo Carbon::now()->toRfc822String(); * ``` * * @return string */ public function toRfc822String(); /** * Format the instance as RFC850 * * @example * ``` * echo Carbon::now()->toRfc850String(); * ``` * * @return string */ public function toRfc850String(); /** * Format the instance as RSS * * @example * ``` * echo Carbon::now()->toRssString(); * ``` * * @return string */ public function toRssString(); /** * Returns english human readable complete date string. * * @example * ``` * echo Carbon::now()->toString(); * ``` * * @return string */ public function toString(); /** * Format the instance as time * * @example * ``` * echo Carbon::now()->toTimeString(); * ``` * * @param string $unitPrecision * * @return string */ public function toTimeString($unitPrecision = 'second'); /** * Format the instance as W3C * * @example * ``` * echo Carbon::now()->toW3cString(); * ``` * * @return string */ public function toW3cString(); /** * Create a Carbon instance for today. * * @param DateTimeZone|string|null $tz * * @return static */ public static function today($tz = null); /** * Create a Carbon instance for tomorrow. * * @param DateTimeZone|string|null $tz * * @return static */ public static function tomorrow($tz = null); /** * Translate using translation string or callback available. * * @param string $key * @param array $parameters * @param string|int|float|null $number * @param \Symfony\Component\Translation\TranslatorInterface|null $translator * @param bool $altNumbers * * @return string */ public function translate(string $key, array $parameters = [], $number = null, ?TranslatorInterface $translator = null, bool $altNumbers = \false) : string; /** * Returns the alternative number for a given integer if available in the current locale. * * @param int $number * * @return string */ public function translateNumber(int $number) : string; /** * Translate a time string from a locale to an other. * * @param string $timeString date/time/duration string to translate (may also contain English) * @param string|null $from input locale of the $timeString parameter (`Carbon::getLocale()` by default) * @param string|null $to output locale of the result returned (`"en"` by default) * @param int $mode 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 string */ public static function translateTimeString($timeString, $from = null, $to = null, $mode = self::TRANSLATE_ALL); /** * Translate a time string from the current locale (`$date->locale()`) to an other. * * @param string $timeString time string to translate * @param string|null $to output locale of the result returned ("en" by default) * * @return string */ public function translateTimeStringTo($timeString, $to = null); /** * Translate using translation string or callback available. * * @param \Symfony\Component\Translation\TranslatorInterface $translator * @param string $key * @param array $parameters * @param null $number * * @return string */ public static function translateWith(TranslatorInterface $translator, string $key, array $parameters = [], $number = null) : 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. * * @param string $format * * @return string */ public function translatedFormat(string $format) : string; /** * Set the timezone or returns the timezone name if no arguments passed. * * @param DateTimeZone|string $value * * @return static|string */ public function tz($value = null); /** * @alias getTimestamp * * Returns the UNIX timestamp for the current date. * * @return int */ public function unix(); /** * @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. * * @param Carbon|\DateTimeInterface|string|array|null $other 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. * @param int|array $syntax 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 * @param bool $short displays short format of time units * @param int $parts maximum number of parts to display (default value: 1: single unit) * @param int $options human diff options * * @return string */ public function until($other = null, $syntax = null, $short = \false, $parts = 1, $options = null); /** * @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. * * @param bool $monthsOverflow * * @return void */ public static function useMonthsOverflow($monthsOverflow = \true); /** * @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). * * @param bool $strictModeEnabled */ public static function useStrictMode($strictModeEnabled = \true); /** * @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. * * @param bool $yearsOverflow * * @return void */ public static function useYearsOverflow($yearsOverflow = \true); /** * Set the instance's timezone to UTC. * * @return static */ public function utc(); /** * Returns the minutes offset to UTC if no arguments passed, else set the timezone with given minutes shift passed. * * @param int|null $minuteOffset * * @return int|static */ public function utcOffset(?int $minuteOffset = null); /** * Returns the milliseconds timestamps used amongst other by Date javascript objects. * * @return float */ public function valueOf(); /** * 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). * * @param int|null $week * @param int|null $dayOfWeek * @param int|null $dayOfYear * * @return int|static */ public function week($week = null, $dayOfWeek = null, $dayOfYear = null); /** * 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). * * @param int|null $year if null, act as a getter, if not null, set the year and return current instance. * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday) * @param int|null $dayOfYear first day of year included in the week #1 * * @return int|static */ public function weekYear($year = null, $dayOfWeek = null, $dayOfYear = null); /** * Get/set the weekday from 0 (Sunday) to 6 (Saturday). * * @param int|null $value new value for weekday if using as setter. * * @return static|int */ public function weekday($value = null); /** * 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). * * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday) * @param int|null $dayOfYear first day of year included in the week #1 * * @return int */ public function weeksInYear($dayOfWeek = null, $dayOfYear = null); /** * Temporarily sets a static date to be used within the callback. * Using setTestNow to set the date, executing the callback, then * clearing the test instance. * * /!\ Use this method for unit tests only. * * @template T * * @param DateTimeInterface|Closure|static|string|false|null $testNow real or mock Carbon instance * @param Closure(): T $callback * * @return T */ public static function withTestNow($testNow, $callback); /** * Create a Carbon instance for yesterday. * * @param DateTimeZone|string|null $tz * * @return static */ public static function yesterday($tz = null); // }