1<?php 2 3/** 4 * This file is part of the Carbon package. 5 * 6 * (c) Brian Nesbitt <brian@nesbot.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace Carbon; 13 14use BadMethodCallException; 15use Carbon\Exceptions\BadComparisonUnitException; 16use Carbon\Exceptions\ImmutableException; 17use Carbon\Exceptions\InvalidDateException; 18use Carbon\Exceptions\InvalidFormatException; 19use Carbon\Exceptions\UnknownGetterException; 20use Carbon\Exceptions\UnknownMethodException; 21use Carbon\Exceptions\UnknownSetterException; 22use Closure; 23use DateInterval; 24use DateTime; 25use DateTimeImmutable; 26use DateTimeInterface; 27use DateTimeZone; 28use JsonSerializable; 29use ReflectionException; 30use ReturnTypeWillChange; 31use Symfony\Component\Translation\TranslatorInterface; 32use Throwable; 33 34/** 35 * Common interface for Carbon and CarbonImmutable. 36 * 37 * <autodoc generated by `composer phpdoc`> 38 * 39 * @property int $year 40 * @property int $yearIso 41 * @property int $month 42 * @property int $day 43 * @property int $hour 44 * @property int $minute 45 * @property int $second 46 * @property int $micro 47 * @property int $microsecond 48 * @property int|float|string $timestamp seconds since the Unix Epoch 49 * @property string $englishDayOfWeek the day of week in English 50 * @property string $shortEnglishDayOfWeek the abbreviated day of week in English 51 * @property string $englishMonth the month in English 52 * @property string $shortEnglishMonth the abbreviated month in English 53 * @property string $localeDayOfWeek the day of week in current locale LC_TIME 54 * @property string $shortLocaleDayOfWeek the abbreviated day of week in current locale LC_TIME 55 * @property string $localeMonth the month in current locale LC_TIME 56 * @property string $shortLocaleMonth the abbreviated month in current locale LC_TIME 57 * @property int $milliseconds 58 * @property int $millisecond 59 * @property int $milli 60 * @property int $week 1 through 53 61 * @property int $isoWeek 1 through 53 62 * @property int $weekYear year according to week format 63 * @property int $isoWeekYear year according to ISO week format 64 * @property int $dayOfYear 1 through 366 65 * @property int $age does a diffInYears() with default parameters 66 * @property int $offset the timezone offset in seconds from UTC 67 * @property int $offsetMinutes the timezone offset in minutes from UTC 68 * @property int $offsetHours the timezone offset in hours from UTC 69 * @property CarbonTimeZone $timezone the current timezone 70 * @property CarbonTimeZone $tz alias of $timezone 71 * @property-read int $dayOfWeek 0 (for Sunday) through 6 (for Saturday) 72 * @property-read int $dayOfWeekIso 1 (for Monday) through 7 (for Sunday) 73 * @property-read int $weekOfYear ISO-8601 week number of year, weeks starting on Monday 74 * @property-read int $daysInMonth number of days in the given month 75 * @property-read string $latinMeridiem "am"/"pm" (Ante meridiem or Post meridiem latin lowercase mark) 76 * @property-read string $latinUpperMeridiem "AM"/"PM" (Ante meridiem or Post meridiem latin uppercase mark) 77 * @property-read string $timezoneAbbreviatedName the current timezone abbreviated name 78 * @property-read string $tzAbbrName alias of $timezoneAbbreviatedName 79 * @property-read string $dayName long name of weekday translated according to Carbon locale, in english if no translation available for current language 80 * @property-read string $shortDayName short name of weekday translated according to Carbon locale, in english if no translation available for current language 81 * @property-read string $minDayName very short name of weekday translated according to Carbon locale, in english if no translation available for current language 82 * @property-read string $monthName long name of month translated according to Carbon locale, in english if no translation available for current language 83 * @property-read string $shortMonthName short name of month translated according to Carbon locale, in english if no translation available for current language 84 * @property-read string $meridiem lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language 85 * @property-read string $upperMeridiem uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language 86 * @property-read int $noZeroHour current hour from 1 to 24 87 * @property-read int $weeksInYear 51 through 53 88 * @property-read int $isoWeeksInYear 51 through 53 89 * @property-read int $weekOfMonth 1 through 5 90 * @property-read int $weekNumberInMonth 1 through 5 91 * @property-read int $firstWeekDay 0 through 6 92 * @property-read int $lastWeekDay 0 through 6 93 * @property-read int $daysInYear 365 or 366 94 * @property-read int $quarter the quarter of this instance, 1 - 4 95 * @property-read int $decade the decade of this instance 96 * @property-read int $century the century of this instance 97 * @property-read int $millennium the millennium of this instance 98 * @property-read bool $dst daylight savings time indicator, true if DST, false otherwise 99 * @property-read bool $local checks if the timezone is local, true if local, false otherwise 100 * @property-read bool $utc checks if the timezone is UTC, true if UTC, false otherwise 101 * @property-read string $timezoneName the current timezone name 102 * @property-read string $tzName alias of $timezoneName 103 * @property-read string $locale locale of the current instance 104 * 105 * @method bool isUtc() Check if the current instance has UTC timezone. (Both isUtc and isUTC cases are valid.) 106 * @method bool isLocal() Check if the current instance has non-UTC timezone. 107 * @method bool isValid() Check if the current instance is a valid date. 108 * @method bool isDST() Check if the current instance is in a daylight saving time. 109 * @method bool isSunday() Checks if the instance day is sunday. 110 * @method bool isMonday() Checks if the instance day is monday. 111 * @method bool isTuesday() Checks if the instance day is tuesday. 112 * @method bool isWednesday() Checks if the instance day is wednesday. 113 * @method bool isThursday() Checks if the instance day is thursday. 114 * @method bool isFriday() Checks if the instance day is friday. 115 * @method bool isSaturday() Checks if the instance day is saturday. 116 * @method bool isSameYear(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same year as the instance. If null passed, compare to now (with the same timezone). 117 * @method bool isCurrentYear() Checks if the instance is in the same year as the current moment. 118 * @method bool isNextYear() Checks if the instance is in the same year as the current moment next year. 119 * @method bool isLastYear() Checks if the instance is in the same year as the current moment last year. 120 * @method bool isSameWeek(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same week as the instance. If null passed, compare to now (with the same timezone). 121 * @method bool isCurrentWeek() Checks if the instance is in the same week as the current moment. 122 * @method bool isNextWeek() Checks if the instance is in the same week as the current moment next week. 123 * @method bool isLastWeek() Checks if the instance is in the same week as the current moment last week. 124 * @method bool isSameDay(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same day as the instance. If null passed, compare to now (with the same timezone). 125 * @method bool isCurrentDay() Checks if the instance is in the same day as the current moment. 126 * @method bool isNextDay() Checks if the instance is in the same day as the current moment next day. 127 * @method bool isLastDay() Checks if the instance is in the same day as the current moment last day. 128 * @method bool isSameHour(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same hour as the instance. If null passed, compare to now (with the same timezone). 129 * @method bool isCurrentHour() Checks if the instance is in the same hour as the current moment. 130 * @method bool isNextHour() Checks if the instance is in the same hour as the current moment next hour. 131 * @method bool isLastHour() Checks if the instance is in the same hour as the current moment last hour. 132 * @method bool isSameMinute(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same minute as the instance. If null passed, compare to now (with the same timezone). 133 * @method bool isCurrentMinute() Checks if the instance is in the same minute as the current moment. 134 * @method bool isNextMinute() Checks if the instance is in the same minute as the current moment next minute. 135 * @method bool isLastMinute() Checks if the instance is in the same minute as the current moment last minute. 136 * @method bool isSameSecond(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same second as the instance. If null passed, compare to now (with the same timezone). 137 * @method bool isCurrentSecond() Checks if the instance is in the same second as the current moment. 138 * @method bool isNextSecond() Checks if the instance is in the same second as the current moment next second. 139 * @method bool isLastSecond() Checks if the instance is in the same second as the current moment last second. 140 * @method bool isSameMicro(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same microsecond as the instance. If null passed, compare to now (with the same timezone). 141 * @method bool isCurrentMicro() Checks if the instance is in the same microsecond as the current moment. 142 * @method bool isNextMicro() Checks if the instance is in the same microsecond as the current moment next microsecond. 143 * @method bool isLastMicro() Checks if the instance is in the same microsecond as the current moment last microsecond. 144 * @method bool isSameMicrosecond(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same microsecond as the instance. If null passed, compare to now (with the same timezone). 145 * @method bool isCurrentMicrosecond() Checks if the instance is in the same microsecond as the current moment. 146 * @method bool isNextMicrosecond() Checks if the instance is in the same microsecond as the current moment next microsecond. 147 * @method bool isLastMicrosecond() Checks if the instance is in the same microsecond as the current moment last microsecond. 148 * @method bool isCurrentMonth() Checks if the instance is in the same month as the current moment. 149 * @method bool isNextMonth() Checks if the instance is in the same month as the current moment next month. 150 * @method bool isLastMonth() Checks if the instance is in the same month as the current moment last month. 151 * @method bool isCurrentQuarter() Checks if the instance is in the same quarter as the current moment. 152 * @method bool isNextQuarter() Checks if the instance is in the same quarter as the current moment next quarter. 153 * @method bool isLastQuarter() Checks if the instance is in the same quarter as the current moment last quarter. 154 * @method bool isSameDecade(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same decade as the instance. If null passed, compare to now (with the same timezone). 155 * @method bool isCurrentDecade() Checks if the instance is in the same decade as the current moment. 156 * @method bool isNextDecade() Checks if the instance is in the same decade as the current moment next decade. 157 * @method bool isLastDecade() Checks if the instance is in the same decade as the current moment last decade. 158 * @method bool isSameCentury(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same century as the instance. If null passed, compare to now (with the same timezone). 159 * @method bool isCurrentCentury() Checks if the instance is in the same century as the current moment. 160 * @method bool isNextCentury() Checks if the instance is in the same century as the current moment next century. 161 * @method bool isLastCentury() Checks if the instance is in the same century as the current moment last century. 162 * @method bool isSameMillennium(Carbon|DateTimeInterface|string|null $date = null) Checks if the given date is in the same millennium as the instance. If null passed, compare to now (with the same timezone). 163 * @method bool isCurrentMillennium() Checks if the instance is in the same millennium as the current moment. 164 * @method bool isNextMillennium() Checks if the instance is in the same millennium as the current moment next millennium. 165 * @method bool isLastMillennium() Checks if the instance is in the same millennium as the current moment last millennium. 166 * @method CarbonInterface years(int $value) Set current instance year to the given value. 167 * @method CarbonInterface year(int $value) Set current instance year to the given value. 168 * @method CarbonInterface setYears(int $value) Set current instance year to the given value. 169 * @method CarbonInterface setYear(int $value) Set current instance year to the given value. 170 * @method CarbonInterface months(int $value) Set current instance month to the given value. 171 * @method CarbonInterface month(int $value) Set current instance month to the given value. 172 * @method CarbonInterface setMonths(int $value) Set current instance month to the given value. 173 * @method CarbonInterface setMonth(int $value) Set current instance month to the given value. 174 * @method CarbonInterface days(int $value) Set current instance day to the given value. 175 * @method CarbonInterface day(int $value) Set current instance day to the given value. 176 * @method CarbonInterface setDays(int $value) Set current instance day to the given value. 177 * @method CarbonInterface setDay(int $value) Set current instance day to the given value. 178 * @method CarbonInterface hours(int $value) Set current instance hour to the given value. 179 * @method CarbonInterface hour(int $value) Set current instance hour to the given value. 180 * @method CarbonInterface setHours(int $value) Set current instance hour to the given value. 181 * @method CarbonInterface setHour(int $value) Set current instance hour to the given value. 182 * @method CarbonInterface minutes(int $value) Set current instance minute to the given value. 183 * @method CarbonInterface minute(int $value) Set current instance minute to the given value. 184 * @method CarbonInterface setMinutes(int $value) Set current instance minute to the given value. 185 * @method CarbonInterface setMinute(int $value) Set current instance minute to the given value. 186 * @method CarbonInterface seconds(int $value) Set current instance second to the given value. 187 * @method CarbonInterface second(int $value) Set current instance second to the given value. 188 * @method CarbonInterface setSeconds(int $value) Set current instance second to the given value. 189 * @method CarbonInterface setSecond(int $value) Set current instance second to the given value. 190 * @method CarbonInterface millis(int $value) Set current instance millisecond to the given value. 191 * @method CarbonInterface milli(int $value) Set current instance millisecond to the given value. 192 * @method CarbonInterface setMillis(int $value) Set current instance millisecond to the given value. 193 * @method CarbonInterface setMilli(int $value) Set current instance millisecond to the given value. 194 * @method CarbonInterface milliseconds(int $value) Set current instance millisecond to the given value. 195 * @method CarbonInterface millisecond(int $value) Set current instance millisecond to the given value. 196 * @method CarbonInterface setMilliseconds(int $value) Set current instance millisecond to the given value. 197 * @method CarbonInterface setMillisecond(int $value) Set current instance millisecond to the given value. 198 * @method CarbonInterface micros(int $value) Set current instance microsecond to the given value. 199 * @method CarbonInterface micro(int $value) Set current instance microsecond to the given value. 200 * @method CarbonInterface setMicros(int $value) Set current instance microsecond to the given value. 201 * @method CarbonInterface setMicro(int $value) Set current instance microsecond to the given value. 202 * @method CarbonInterface microseconds(int $value) Set current instance microsecond to the given value. 203 * @method CarbonInterface microsecond(int $value) Set current instance microsecond to the given value. 204 * @method CarbonInterface setMicroseconds(int $value) Set current instance microsecond to the given value. 205 * @method CarbonInterface setMicrosecond(int $value) Set current instance microsecond to the given value. 206 * @method CarbonInterface addYears(int $value = 1) Add years (the $value count passed in) to the instance (using date interval). 207 * @method CarbonInterface addYear() Add one year to the instance (using date interval). 208 * @method CarbonInterface subYears(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval). 209 * @method CarbonInterface subYear() Sub one year to the instance (using date interval). 210 * @method CarbonInterface addYearsWithOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. 211 * @method CarbonInterface addYearWithOverflow() Add one year to the instance (using date interval) with overflow explicitly allowed. 212 * @method CarbonInterface subYearsWithOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. 213 * @method CarbonInterface subYearWithOverflow() Sub one year to the instance (using date interval) with overflow explicitly allowed. 214 * @method CarbonInterface addYearsWithoutOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 215 * @method CarbonInterface addYearWithoutOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. 216 * @method CarbonInterface subYearsWithoutOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 217 * @method CarbonInterface subYearWithoutOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. 218 * @method CarbonInterface addYearsWithNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 219 * @method CarbonInterface addYearWithNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. 220 * @method CarbonInterface subYearsWithNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 221 * @method CarbonInterface subYearWithNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. 222 * @method CarbonInterface addYearsNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 223 * @method CarbonInterface addYearNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. 224 * @method CarbonInterface subYearsNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 225 * @method CarbonInterface subYearNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. 226 * @method CarbonInterface addMonths(int $value = 1) Add months (the $value count passed in) to the instance (using date interval). 227 * @method CarbonInterface addMonth() Add one month to the instance (using date interval). 228 * @method CarbonInterface subMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval). 229 * @method CarbonInterface subMonth() Sub one month to the instance (using date interval). 230 * @method CarbonInterface addMonthsWithOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. 231 * @method CarbonInterface addMonthWithOverflow() Add one month to the instance (using date interval) with overflow explicitly allowed. 232 * @method CarbonInterface subMonthsWithOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. 233 * @method CarbonInterface subMonthWithOverflow() Sub one month to the instance (using date interval) with overflow explicitly allowed. 234 * @method CarbonInterface addMonthsWithoutOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 235 * @method CarbonInterface addMonthWithoutOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. 236 * @method CarbonInterface subMonthsWithoutOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 237 * @method CarbonInterface subMonthWithoutOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. 238 * @method CarbonInterface addMonthsWithNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 239 * @method CarbonInterface addMonthWithNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. 240 * @method CarbonInterface subMonthsWithNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 241 * @method CarbonInterface subMonthWithNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. 242 * @method CarbonInterface addMonthsNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 243 * @method CarbonInterface addMonthNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. 244 * @method CarbonInterface subMonthsNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 245 * @method CarbonInterface subMonthNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. 246 * @method CarbonInterface addDays(int $value = 1) Add days (the $value count passed in) to the instance (using date interval). 247 * @method CarbonInterface addDay() Add one day to the instance (using date interval). 248 * @method CarbonInterface subDays(int $value = 1) Sub days (the $value count passed in) to the instance (using date interval). 249 * @method CarbonInterface subDay() Sub one day to the instance (using date interval). 250 * @method CarbonInterface addHours(int $value = 1) Add hours (the $value count passed in) to the instance (using date interval). 251 * @method CarbonInterface addHour() Add one hour to the instance (using date interval). 252 * @method CarbonInterface subHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using date interval). 253 * @method CarbonInterface subHour() Sub one hour to the instance (using date interval). 254 * @method CarbonInterface addMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using date interval). 255 * @method CarbonInterface addMinute() Add one minute to the instance (using date interval). 256 * @method CarbonInterface subMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval). 257 * @method CarbonInterface subMinute() Sub one minute to the instance (using date interval). 258 * @method CarbonInterface addSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using date interval). 259 * @method CarbonInterface addSecond() Add one second to the instance (using date interval). 260 * @method CarbonInterface subSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval). 261 * @method CarbonInterface subSecond() Sub one second to the instance (using date interval). 262 * @method CarbonInterface addMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). 263 * @method CarbonInterface addMilli() Add one millisecond to the instance (using date interval). 264 * @method CarbonInterface subMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). 265 * @method CarbonInterface subMilli() Sub one millisecond to the instance (using date interval). 266 * @method CarbonInterface addMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). 267 * @method CarbonInterface addMillisecond() Add one millisecond to the instance (using date interval). 268 * @method CarbonInterface subMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). 269 * @method CarbonInterface subMillisecond() Sub one millisecond to the instance (using date interval). 270 * @method CarbonInterface addMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). 271 * @method CarbonInterface addMicro() Add one microsecond to the instance (using date interval). 272 * @method CarbonInterface subMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). 273 * @method CarbonInterface subMicro() Sub one microsecond to the instance (using date interval). 274 * @method CarbonInterface addMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). 275 * @method CarbonInterface addMicrosecond() Add one microsecond to the instance (using date interval). 276 * @method CarbonInterface subMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). 277 * @method CarbonInterface subMicrosecond() Sub one microsecond to the instance (using date interval). 278 * @method CarbonInterface addMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval). 279 * @method CarbonInterface addMillennium() Add one millennium to the instance (using date interval). 280 * @method CarbonInterface subMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval). 281 * @method CarbonInterface subMillennium() Sub one millennium to the instance (using date interval). 282 * @method CarbonInterface addMillenniaWithOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. 283 * @method CarbonInterface addMillenniumWithOverflow() Add one millennium to the instance (using date interval) with overflow explicitly allowed. 284 * @method CarbonInterface subMillenniaWithOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. 285 * @method CarbonInterface subMillenniumWithOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly allowed. 286 * @method CarbonInterface addMillenniaWithoutOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 287 * @method CarbonInterface addMillenniumWithoutOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. 288 * @method CarbonInterface subMillenniaWithoutOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 289 * @method CarbonInterface subMillenniumWithoutOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. 290 * @method CarbonInterface addMillenniaWithNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 291 * @method CarbonInterface addMillenniumWithNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. 292 * @method CarbonInterface subMillenniaWithNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 293 * @method CarbonInterface subMillenniumWithNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. 294 * @method CarbonInterface addMillenniaNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 295 * @method CarbonInterface addMillenniumNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. 296 * @method CarbonInterface subMillenniaNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 297 * @method CarbonInterface subMillenniumNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. 298 * @method CarbonInterface addCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval). 299 * @method CarbonInterface addCentury() Add one century to the instance (using date interval). 300 * @method CarbonInterface subCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval). 301 * @method CarbonInterface subCentury() Sub one century to the instance (using date interval). 302 * @method CarbonInterface addCenturiesWithOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. 303 * @method CarbonInterface addCenturyWithOverflow() Add one century to the instance (using date interval) with overflow explicitly allowed. 304 * @method CarbonInterface subCenturiesWithOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. 305 * @method CarbonInterface subCenturyWithOverflow() Sub one century to the instance (using date interval) with overflow explicitly allowed. 306 * @method CarbonInterface addCenturiesWithoutOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 307 * @method CarbonInterface addCenturyWithoutOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. 308 * @method CarbonInterface subCenturiesWithoutOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 309 * @method CarbonInterface subCenturyWithoutOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. 310 * @method CarbonInterface addCenturiesWithNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 311 * @method CarbonInterface addCenturyWithNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. 312 * @method CarbonInterface subCenturiesWithNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 313 * @method CarbonInterface subCenturyWithNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. 314 * @method CarbonInterface addCenturiesNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 315 * @method CarbonInterface addCenturyNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. 316 * @method CarbonInterface subCenturiesNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 317 * @method CarbonInterface subCenturyNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. 318 * @method CarbonInterface addDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval). 319 * @method CarbonInterface addDecade() Add one decade to the instance (using date interval). 320 * @method CarbonInterface subDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval). 321 * @method CarbonInterface subDecade() Sub one decade to the instance (using date interval). 322 * @method CarbonInterface addDecadesWithOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. 323 * @method CarbonInterface addDecadeWithOverflow() Add one decade to the instance (using date interval) with overflow explicitly allowed. 324 * @method CarbonInterface subDecadesWithOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. 325 * @method CarbonInterface subDecadeWithOverflow() Sub one decade to the instance (using date interval) with overflow explicitly allowed. 326 * @method CarbonInterface addDecadesWithoutOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 327 * @method CarbonInterface addDecadeWithoutOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. 328 * @method CarbonInterface subDecadesWithoutOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 329 * @method CarbonInterface subDecadeWithoutOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. 330 * @method CarbonInterface addDecadesWithNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 331 * @method CarbonInterface addDecadeWithNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. 332 * @method CarbonInterface subDecadesWithNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 333 * @method CarbonInterface subDecadeWithNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. 334 * @method CarbonInterface addDecadesNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 335 * @method CarbonInterface addDecadeNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. 336 * @method CarbonInterface subDecadesNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 337 * @method CarbonInterface subDecadeNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. 338 * @method CarbonInterface addQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval). 339 * @method CarbonInterface addQuarter() Add one quarter to the instance (using date interval). 340 * @method CarbonInterface subQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval). 341 * @method CarbonInterface subQuarter() Sub one quarter to the instance (using date interval). 342 * @method CarbonInterface addQuartersWithOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. 343 * @method CarbonInterface addQuarterWithOverflow() Add one quarter to the instance (using date interval) with overflow explicitly allowed. 344 * @method CarbonInterface subQuartersWithOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. 345 * @method CarbonInterface subQuarterWithOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly allowed. 346 * @method CarbonInterface addQuartersWithoutOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 347 * @method CarbonInterface addQuarterWithoutOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. 348 * @method CarbonInterface subQuartersWithoutOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 349 * @method CarbonInterface subQuarterWithoutOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. 350 * @method CarbonInterface addQuartersWithNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 351 * @method CarbonInterface addQuarterWithNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. 352 * @method CarbonInterface subQuartersWithNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 353 * @method CarbonInterface subQuarterWithNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. 354 * @method CarbonInterface addQuartersNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 355 * @method CarbonInterface addQuarterNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. 356 * @method CarbonInterface subQuartersNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. 357 * @method CarbonInterface subQuarterNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. 358 * @method CarbonInterface addWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using date interval). 359 * @method CarbonInterface addWeek() Add one week to the instance (using date interval). 360 * @method CarbonInterface subWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval). 361 * @method CarbonInterface subWeek() Sub one week to the instance (using date interval). 362 * @method CarbonInterface addWeekdays(int $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval). 363 * @method CarbonInterface addWeekday() Add one weekday to the instance (using date interval). 364 * @method CarbonInterface subWeekdays(int $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval). 365 * @method CarbonInterface subWeekday() Sub one weekday to the instance (using date interval). 366 * @method CarbonInterface addRealMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). 367 * @method CarbonInterface addRealMicro() Add one microsecond to the instance (using timestamp). 368 * @method CarbonInterface subRealMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). 369 * @method CarbonInterface subRealMicro() Sub one microsecond to the instance (using timestamp). 370 * @method CarbonPeriod microsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. 371 * @method CarbonInterface addRealMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). 372 * @method CarbonInterface addRealMicrosecond() Add one microsecond to the instance (using timestamp). 373 * @method CarbonInterface subRealMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). 374 * @method CarbonInterface subRealMicrosecond() Sub one microsecond to the instance (using timestamp). 375 * @method CarbonPeriod microsecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each microsecond or every X microseconds if a factor is given. 376 * @method CarbonInterface addRealMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). 377 * @method CarbonInterface addRealMilli() Add one millisecond to the instance (using timestamp). 378 * @method CarbonInterface subRealMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). 379 * @method CarbonInterface subRealMilli() Sub one millisecond to the instance (using timestamp). 380 * @method CarbonPeriod millisUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. 381 * @method CarbonInterface addRealMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). 382 * @method CarbonInterface addRealMillisecond() Add one millisecond to the instance (using timestamp). 383 * @method CarbonInterface subRealMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). 384 * @method CarbonInterface subRealMillisecond() Sub one millisecond to the instance (using timestamp). 385 * @method CarbonPeriod millisecondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millisecond or every X milliseconds if a factor is given. 386 * @method CarbonInterface addRealSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp). 387 * @method CarbonInterface addRealSecond() Add one second to the instance (using timestamp). 388 * @method CarbonInterface subRealSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp). 389 * @method CarbonInterface subRealSecond() Sub one second to the instance (using timestamp). 390 * @method CarbonPeriod secondsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each second or every X seconds if a factor is given. 391 * @method CarbonInterface addRealMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp). 392 * @method CarbonInterface addRealMinute() Add one minute to the instance (using timestamp). 393 * @method CarbonInterface subRealMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp). 394 * @method CarbonInterface subRealMinute() Sub one minute to the instance (using timestamp). 395 * @method CarbonPeriod minutesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each minute or every X minutes if a factor is given. 396 * @method CarbonInterface addRealHours(int $value = 1) Add hours (the $value count passed in) to the instance (using timestamp). 397 * @method CarbonInterface addRealHour() Add one hour to the instance (using timestamp). 398 * @method CarbonInterface subRealHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp). 399 * @method CarbonInterface subRealHour() Sub one hour to the instance (using timestamp). 400 * @method CarbonPeriod hoursUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each hour or every X hours if a factor is given. 401 * @method CarbonInterface addRealDays(int $value = 1) Add days (the $value count passed in) to the instance (using timestamp). 402 * @method CarbonInterface addRealDay() Add one day to the instance (using timestamp). 403 * @method CarbonInterface subRealDays(int $value = 1) Sub days (the $value count passed in) to the instance (using timestamp). 404 * @method CarbonInterface subRealDay() Sub one day to the instance (using timestamp). 405 * @method CarbonPeriod daysUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each day or every X days if a factor is given. 406 * @method CarbonInterface addRealWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp). 407 * @method CarbonInterface addRealWeek() Add one week to the instance (using timestamp). 408 * @method CarbonInterface subRealWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp). 409 * @method CarbonInterface subRealWeek() Sub one week to the instance (using timestamp). 410 * @method CarbonPeriod weeksUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each week or every X weeks if a factor is given. 411 * @method CarbonInterface addRealMonths(int $value = 1) Add months (the $value count passed in) to the instance (using timestamp). 412 * @method CarbonInterface addRealMonth() Add one month to the instance (using timestamp). 413 * @method CarbonInterface subRealMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using timestamp). 414 * @method CarbonInterface subRealMonth() Sub one month to the instance (using timestamp). 415 * @method CarbonPeriod monthsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each month or every X months if a factor is given. 416 * @method CarbonInterface addRealQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp). 417 * @method CarbonInterface addRealQuarter() Add one quarter to the instance (using timestamp). 418 * @method CarbonInterface subRealQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp). 419 * @method CarbonInterface subRealQuarter() Sub one quarter to the instance (using timestamp). 420 * @method CarbonPeriod quartersUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each quarter or every X quarters if a factor is given. 421 * @method CarbonInterface addRealYears(int $value = 1) Add years (the $value count passed in) to the instance (using timestamp). 422 * @method CarbonInterface addRealYear() Add one year to the instance (using timestamp). 423 * @method CarbonInterface subRealYears(int $value = 1) Sub years (the $value count passed in) to the instance (using timestamp). 424 * @method CarbonInterface subRealYear() Sub one year to the instance (using timestamp). 425 * @method CarbonPeriod yearsUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each year or every X years if a factor is given. 426 * @method CarbonInterface addRealDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using timestamp). 427 * @method CarbonInterface addRealDecade() Add one decade to the instance (using timestamp). 428 * @method CarbonInterface subRealDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp). 429 * @method CarbonInterface subRealDecade() Sub one decade to the instance (using timestamp). 430 * @method CarbonPeriod decadesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each decade or every X decades if a factor is given. 431 * @method CarbonInterface addRealCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp). 432 * @method CarbonInterface addRealCentury() Add one century to the instance (using timestamp). 433 * @method CarbonInterface subRealCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp). 434 * @method CarbonInterface subRealCentury() Sub one century to the instance (using timestamp). 435 * @method CarbonPeriod centuriesUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each century or every X centuries if a factor is given. 436 * @method CarbonInterface addRealMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp). 437 * @method CarbonInterface addRealMillennium() Add one millennium to the instance (using timestamp). 438 * @method CarbonInterface subRealMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp). 439 * @method CarbonInterface subRealMillennium() Sub one millennium to the instance (using timestamp). 440 * @method CarbonPeriod millenniaUntil($endDate = null, int $factor = 1) Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each millennium or every X millennia if a factor is given. 441 * @method CarbonInterface roundYear(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. 442 * @method CarbonInterface roundYears(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. 443 * @method CarbonInterface floorYear(float $precision = 1) Truncate the current instance year with given precision. 444 * @method CarbonInterface floorYears(float $precision = 1) Truncate the current instance year with given precision. 445 * @method CarbonInterface ceilYear(float $precision = 1) Ceil the current instance year with given precision. 446 * @method CarbonInterface ceilYears(float $precision = 1) Ceil the current instance year with given precision. 447 * @method CarbonInterface roundMonth(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function. 448 * @method CarbonInterface roundMonths(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function. 449 * @method CarbonInterface floorMonth(float $precision = 1) Truncate the current instance month with given precision. 450 * @method CarbonInterface floorMonths(float $precision = 1) Truncate the current instance month with given precision. 451 * @method CarbonInterface ceilMonth(float $precision = 1) Ceil the current instance month with given precision. 452 * @method CarbonInterface ceilMonths(float $precision = 1) Ceil the current instance month with given precision. 453 * @method CarbonInterface roundDay(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function. 454 * @method CarbonInterface roundDays(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function. 455 * @method CarbonInterface floorDay(float $precision = 1) Truncate the current instance day with given precision. 456 * @method CarbonInterface floorDays(float $precision = 1) Truncate the current instance day with given precision. 457 * @method CarbonInterface ceilDay(float $precision = 1) Ceil the current instance day with given precision. 458 * @method CarbonInterface ceilDays(float $precision = 1) Ceil the current instance day with given precision. 459 * @method CarbonInterface roundHour(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function. 460 * @method CarbonInterface roundHours(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function. 461 * @method CarbonInterface floorHour(float $precision = 1) Truncate the current instance hour with given precision. 462 * @method CarbonInterface floorHours(float $precision = 1) Truncate the current instance hour with given precision. 463 * @method CarbonInterface ceilHour(float $precision = 1) Ceil the current instance hour with given precision. 464 * @method CarbonInterface ceilHours(float $precision = 1) Ceil the current instance hour with given precision. 465 * @method CarbonInterface roundMinute(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function. 466 * @method CarbonInterface roundMinutes(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function. 467 * @method CarbonInterface floorMinute(float $precision = 1) Truncate the current instance minute with given precision. 468 * @method CarbonInterface floorMinutes(float $precision = 1) Truncate the current instance minute with given precision. 469 * @method CarbonInterface ceilMinute(float $precision = 1) Ceil the current instance minute with given precision. 470 * @method CarbonInterface ceilMinutes(float $precision = 1) Ceil the current instance minute with given precision. 471 * @method CarbonInterface roundSecond(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function. 472 * @method CarbonInterface roundSeconds(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function. 473 * @method CarbonInterface floorSecond(float $precision = 1) Truncate the current instance second with given precision. 474 * @method CarbonInterface floorSeconds(float $precision = 1) Truncate the current instance second with given precision. 475 * @method CarbonInterface ceilSecond(float $precision = 1) Ceil the current instance second with given precision. 476 * @method CarbonInterface ceilSeconds(float $precision = 1) Ceil the current instance second with given precision. 477 * @method CarbonInterface roundMillennium(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function. 478 * @method CarbonInterface roundMillennia(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function. 479 * @method CarbonInterface floorMillennium(float $precision = 1) Truncate the current instance millennium with given precision. 480 * @method CarbonInterface floorMillennia(float $precision = 1) Truncate the current instance millennium with given precision. 481 * @method CarbonInterface ceilMillennium(float $precision = 1) Ceil the current instance millennium with given precision. 482 * @method CarbonInterface ceilMillennia(float $precision = 1) Ceil the current instance millennium with given precision. 483 * @method CarbonInterface roundCentury(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function. 484 * @method CarbonInterface roundCenturies(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function. 485 * @method CarbonInterface floorCentury(float $precision = 1) Truncate the current instance century with given precision. 486 * @method CarbonInterface floorCenturies(float $precision = 1) Truncate the current instance century with given precision. 487 * @method CarbonInterface ceilCentury(float $precision = 1) Ceil the current instance century with given precision. 488 * @method CarbonInterface ceilCenturies(float $precision = 1) Ceil the current instance century with given precision. 489 * @method CarbonInterface roundDecade(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function. 490 * @method CarbonInterface roundDecades(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function. 491 * @method CarbonInterface floorDecade(float $precision = 1) Truncate the current instance decade with given precision. 492 * @method CarbonInterface floorDecades(float $precision = 1) Truncate the current instance decade with given precision. 493 * @method CarbonInterface ceilDecade(float $precision = 1) Ceil the current instance decade with given precision. 494 * @method CarbonInterface ceilDecades(float $precision = 1) Ceil the current instance decade with given precision. 495 * @method CarbonInterface roundQuarter(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function. 496 * @method CarbonInterface roundQuarters(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function. 497 * @method CarbonInterface floorQuarter(float $precision = 1) Truncate the current instance quarter with given precision. 498 * @method CarbonInterface floorQuarters(float $precision = 1) Truncate the current instance quarter with given precision. 499 * @method CarbonInterface ceilQuarter(float $precision = 1) Ceil the current instance quarter with given precision. 500 * @method CarbonInterface ceilQuarters(float $precision = 1) Ceil the current instance quarter with given precision. 501 * @method CarbonInterface roundMillisecond(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function. 502 * @method CarbonInterface roundMilliseconds(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function. 503 * @method CarbonInterface floorMillisecond(float $precision = 1) Truncate the current instance millisecond with given precision. 504 * @method CarbonInterface floorMilliseconds(float $precision = 1) Truncate the current instance millisecond with given precision. 505 * @method CarbonInterface ceilMillisecond(float $precision = 1) Ceil the current instance millisecond with given precision. 506 * @method CarbonInterface ceilMilliseconds(float $precision = 1) Ceil the current instance millisecond with given precision. 507 * @method CarbonInterface roundMicrosecond(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function. 508 * @method CarbonInterface roundMicroseconds(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function. 509 * @method CarbonInterface floorMicrosecond(float $precision = 1) Truncate the current instance microsecond with given precision. 510 * @method CarbonInterface floorMicroseconds(float $precision = 1) Truncate the current instance microsecond with given precision. 511 * @method CarbonInterface ceilMicrosecond(float $precision = 1) Ceil the current instance microsecond with given precision. 512 * @method CarbonInterface ceilMicroseconds(float $precision = 1) Ceil the current instance microsecond with given precision. 513 * @method string shortAbsoluteDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'Absolute' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) 514 * @method string longAbsoluteDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'Absolute' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) 515 * @method string shortRelativeDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'Relative' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) 516 * @method string longRelativeDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'Relative' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) 517 * @method string shortRelativeToNowDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) 518 * @method string longRelativeToNowDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToNow' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) 519 * @method string shortRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (short format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) 520 * @method string longRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) 521 * 522 * </autodoc> 523 */ 524interface CarbonInterface extends DateTimeInterface, JsonSerializable 525{ 526 /** 527 * Diff wording options(expressed in octal). 528 */ 529 public const NO_ZERO_DIFF = 01; 530 public const JUST_NOW = 02; 531 public const ONE_DAY_WORDS = 04; 532 public const TWO_DAY_WORDS = 010; 533 public const SEQUENTIAL_PARTS_ONLY = 020; 534 public const ROUND = 040; 535 public const FLOOR = 0100; 536 public const CEIL = 0200; 537 538 /** 539 * Diff syntax options. 540 */ 541 public const DIFF_ABSOLUTE = 1; // backward compatibility with true 542 public const DIFF_RELATIVE_AUTO = 0; // backward compatibility with false 543 public const DIFF_RELATIVE_TO_NOW = 2; 544 public const DIFF_RELATIVE_TO_OTHER = 3; 545 546 /** 547 * Translate string options. 548 */ 549 public const TRANSLATE_MONTHS = 1; 550 public const TRANSLATE_DAYS = 2; 551 public const TRANSLATE_UNITS = 4; 552 public const TRANSLATE_MERIDIEM = 8; 553 public const TRANSLATE_DIFF = 0x10; 554 public const TRANSLATE_ALL = self::TRANSLATE_MONTHS | self::TRANSLATE_DAYS | self::TRANSLATE_UNITS | self::TRANSLATE_MERIDIEM | self::TRANSLATE_DIFF; 555 556 /** 557 * The day constants. 558 */ 559 public const SUNDAY = 0; 560 public const MONDAY = 1; 561 public const TUESDAY = 2; 562 public const WEDNESDAY = 3; 563 public const THURSDAY = 4; 564 public const FRIDAY = 5; 565 public const SATURDAY = 6; 566 567 /** 568 * The month constants. 569 * These aren't used by Carbon itself but exist for 570 * convenience sake alone. 571 */ 572 public const JANUARY = 1; 573 public const FEBRUARY = 2; 574 public const MARCH = 3; 575 public const APRIL = 4; 576 public const MAY = 5; 577 public const JUNE = 6; 578 public const JULY = 7; 579 public const AUGUST = 8; 580 public const SEPTEMBER = 9; 581 public const OCTOBER = 10; 582 public const NOVEMBER = 11; 583 public const DECEMBER = 12; 584 585 /** 586 * Number of X in Y. 587 */ 588 public const YEARS_PER_MILLENNIUM = 1000; 589 public const YEARS_PER_CENTURY = 100; 590 public const YEARS_PER_DECADE = 10; 591 public const MONTHS_PER_YEAR = 12; 592 public const MONTHS_PER_QUARTER = 3; 593 public const WEEKS_PER_YEAR = 52; 594 public const WEEKS_PER_MONTH = 4; 595 public const DAYS_PER_YEAR = 365; 596 public const DAYS_PER_WEEK = 7; 597 public const HOURS_PER_DAY = 24; 598 public const MINUTES_PER_HOUR = 60; 599 public const SECONDS_PER_MINUTE = 60; 600 public const MILLISECONDS_PER_SECOND = 1000; 601 public const MICROSECONDS_PER_MILLISECOND = 1000; 602 public const MICROSECONDS_PER_SECOND = 1000000; 603 604 /** 605 * Special settings to get the start of week from current locale culture. 606 */ 607 public const WEEK_DAY_AUTO = 'auto'; 608 609 /** 610 * RFC7231 DateTime format. 611 * 612 * @var string 613 */ 614 public const RFC7231_FORMAT = 'D, d M Y H:i:s \G\M\T'; 615 616 /** 617 * Default format to use for __toString method when type juggling occurs. 618 * 619 * @var string 620 */ 621 public const DEFAULT_TO_STRING_FORMAT = 'Y-m-d H:i:s'; 622 623 /** 624 * Format for converting mocked time, includes microseconds. 625 * 626 * @var string 627 */ 628 public const MOCK_DATETIME_FORMAT = 'Y-m-d H:i:s.u'; 629 630 /** 631 * Pattern detection for ->isoFormat and ::createFromIsoFormat. 632 * 633 * @var string 634 */ 635 public const 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?)'; 636 637 // <methods> 638 639 /** 640 * Dynamically handle calls to the class. 641 * 642 * @param string $method magic method name called 643 * @param array $parameters parameters list 644 * 645 * @throws UnknownMethodException|BadMethodCallException|ReflectionException|Throwable 646 * 647 * @return mixed 648 */ 649 public function __call($method, $parameters); 650 651 /** 652 * Dynamically handle calls to the class. 653 * 654 * @param string $method magic method name called 655 * @param array $parameters parameters list 656 * 657 * @throws BadMethodCallException 658 * 659 * @return mixed 660 */ 661 public static function __callStatic($method, $parameters); 662 663 /** 664 * Update constructedObjectId on cloned. 665 */ 666 public function __clone(); 667 668 /** 669 * Create a new Carbon instance. 670 * 671 * Please see the testing aids section (specifically static::setTestNow()) 672 * for more on the possibility of this constructor returning a test instance. 673 * 674 * @param DateTimeInterface|string|null $time 675 * @param DateTimeZone|string|null $tz 676 * 677 * @throws InvalidFormatException 678 */ 679 public function __construct($time = null, $tz = null); 680 681 /** 682 * Show truthy properties on var_dump(). 683 * 684 * @return array 685 */ 686 public function __debugInfo(); 687 688 /** 689 * Get a part of the Carbon object 690 * 691 * @param string $name 692 * 693 * @throws UnknownGetterException 694 * 695 * @return string|int|bool|DateTimeZone|null 696 */ 697 public function __get($name); 698 699 /** 700 * Check if an attribute exists on the object 701 * 702 * @param string $name 703 * 704 * @return bool 705 */ 706 public function __isset($name); 707 708 /** 709 * Set a part of the Carbon object 710 * 711 * @param string $name 712 * @param string|int|DateTimeZone $value 713 * 714 * @throws UnknownSetterException|ReflectionException 715 * 716 * @return void 717 */ 718 public function __set($name, $value); 719 720 /** 721 * The __set_state handler. 722 * 723 * @param string|array $dump 724 * 725 * @return static 726 */ 727 #[ReturnTypeWillChange] 728 public static function __set_state($dump); 729 730 /** 731 * Returns the list of properties to dump on serialize() called on. 732 * 733 * @return array 734 */ 735 public function __sleep(); 736 737 /** 738 * Format the instance as a string using the set format 739 * 740 * @example 741 * ``` 742 * echo Carbon::now(); // Carbon instances can be casted to string 743 * ``` 744 * 745 * @return string 746 */ 747 public function __toString(); 748 749 /** 750 * Add given units or interval to the current instance. 751 * 752 * @example $date->add('hour', 3) 753 * @example $date->add(15, 'days') 754 * @example $date->add(CarbonInterval::days(4)) 755 * 756 * @param string|DateInterval|Closure|CarbonConverterInterface $unit 757 * @param int $value 758 * @param bool|null $overflow 759 * 760 * @return static 761 */ 762 #[ReturnTypeWillChange] 763 public function add($unit, $value = 1, $overflow = null); 764 765 /** 766 * Add seconds to the instance using timestamp. Positive $value travels 767 * forward while negative $value travels into the past. 768 * 769 * @param string $unit 770 * @param int $value 771 * 772 * @return static 773 */ 774 public function addRealUnit($unit, $value = 1); 775 776 /** 777 * Add given units to the current instance. 778 * 779 * @param string $unit 780 * @param int $value 781 * @param bool|null $overflow 782 * 783 * @return static 784 */ 785 public function addUnit($unit, $value = 1, $overflow = null); 786 787 /** 788 * Add any unit to a new value without overflowing current other unit given. 789 * 790 * @param string $valueUnit unit name to modify 791 * @param int $value amount to add to the input unit 792 * @param string $overflowUnit unit name to not overflow 793 * 794 * @return static 795 */ 796 public function addUnitNoOverflow($valueUnit, $value, $overflowUnit); 797 798 /** 799 * Get the difference in a human readable format in the current locale from an other 800 * instance given to now 801 * 802 * @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains: 803 * - 'syntax' entry (see below) 804 * - 'short' entry (see below) 805 * - 'parts' entry (see below) 806 * - 'options' entry (see below) 807 * - 'join' entry determines how to join multiple parts of the string 808 * ` - if $join is a string, it's used as a joiner glue 809 * ` - if $join is a callable/closure, it get the list of string and should return a string 810 * ` - if $join is an array, the first item will be the default glue, and the second item 811 * ` will be used instead of the glue for the last item 812 * ` - if $join is true, it will be guessed from the locale ('list' translation file entry) 813 * ` - if $join is missing, a space will be used as glue 814 * if int passed, it add modifiers: 815 * Possible values: 816 * - CarbonInterface::DIFF_ABSOLUTE no modifiers 817 * - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier 818 * - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier 819 * Default value: CarbonInterface::DIFF_ABSOLUTE 820 * @param bool $short displays short format of time units 821 * @param int $parts maximum number of parts to display (default value: 1: single part) 822 * @param int $options human diff options 823 * 824 * @return string 825 */ 826 public function ago($syntax = null, $short = false, $parts = 1, $options = null); 827 828 /** 829 * Modify the current instance to the average of a given instance (default now) and the current instance 830 * (second-precision). 831 * 832 * @param \Carbon\Carbon|\DateTimeInterface|null $date 833 * 834 * @return static 835 */ 836 public function average($date = null); 837 838 /** 839 * Clone the current instance if it's mutable. 840 * 841 * This method is convenient to ensure you don't mutate the initial object 842 * but avoid to make a useless copy of it if it's already immutable. 843 * 844 * @return static 845 */ 846 public function avoidMutation(); 847 848 /** 849 * Determines if the instance is between two others. 850 * 851 * The third argument allow you to specify if bounds are included or not (true by default) 852 * but for when you including/excluding bounds may produce different results in your application, 853 * we recommend to use the explicit methods ->betweenIncluded() or ->betweenExcluded() instead. 854 * 855 * @example 856 * ``` 857 * Carbon::parse('2018-07-25')->between('2018-07-14', '2018-08-01'); // true 858 * Carbon::parse('2018-07-25')->between('2018-08-01', '2018-08-20'); // false 859 * Carbon::parse('2018-07-25')->between('2018-07-25', '2018-08-01'); // true 860 * Carbon::parse('2018-07-25')->between('2018-07-25', '2018-08-01', false); // false 861 * ``` 862 * 863 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date1 864 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date2 865 * @param bool $equal Indicates if an equal to comparison should be done 866 * 867 * @return bool 868 */ 869 public function between($date1, $date2, $equal = true): bool; 870 871 /** 872 * Determines if the instance is between two others, bounds excluded. 873 * 874 * @example 875 * ``` 876 * Carbon::parse('2018-07-25')->betweenExcluded('2018-07-14', '2018-08-01'); // true 877 * Carbon::parse('2018-07-25')->betweenExcluded('2018-08-01', '2018-08-20'); // false 878 * Carbon::parse('2018-07-25')->betweenExcluded('2018-07-25', '2018-08-01'); // false 879 * ``` 880 * 881 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date1 882 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date2 883 * 884 * @return bool 885 */ 886 public function betweenExcluded($date1, $date2): bool; 887 888 /** 889 * Determines if the instance is between two others, bounds included. 890 * 891 * @example 892 * ``` 893 * Carbon::parse('2018-07-25')->betweenIncluded('2018-07-14', '2018-08-01'); // true 894 * Carbon::parse('2018-07-25')->betweenIncluded('2018-08-01', '2018-08-20'); // false 895 * Carbon::parse('2018-07-25')->betweenIncluded('2018-07-25', '2018-08-01'); // true 896 * ``` 897 * 898 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date1 899 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date2 900 * 901 * @return bool 902 */ 903 public function betweenIncluded($date1, $date2): bool; 904 905 /** 906 * Returns either day of week + time (e.g. "Last Friday at 3:30 PM") if reference time is within 7 days, 907 * or a calendar date (e.g. "10/29/2017") otherwise. 908 * 909 * Language, date and time formats will change according to the current locale. 910 * 911 * @param Carbon|\DateTimeInterface|string|null $referenceTime 912 * @param array $formats 913 * 914 * @return string 915 */ 916 public function calendar($referenceTime = null, array $formats = []); 917 918 /** 919 * Checks if the (date)time string is in a given format and valid to create a 920 * new instance. 921 * 922 * @example 923 * ``` 924 * Carbon::canBeCreatedFromFormat('11:12:45', 'h:i:s'); // true 925 * Carbon::canBeCreatedFromFormat('13:12:45', 'h:i:s'); // false 926 * ``` 927 * 928 * @param string $date 929 * @param string $format 930 * 931 * @return bool 932 */ 933 public static function canBeCreatedFromFormat($date, $format); 934 935 /** 936 * Return the Carbon instance passed through, a now instance in the same timezone 937 * if null given or parse the input if string given. 938 * 939 * @param Carbon|\Carbon\CarbonPeriod|\Carbon\CarbonInterval|\DateInterval|\DatePeriod|DateTimeInterface|string|null $date 940 * 941 * @return static 942 */ 943 public function carbonize($date = null); 944 945 /** 946 * Cast the current instance into the given class. 947 * 948 * @param string $className The $className::instance() method will be called to cast the current object. 949 * 950 * @return DateTimeInterface 951 */ 952 public function cast(string $className); 953 954 /** 955 * Ceil the current instance second with given precision if specified. 956 * 957 * @param float|int|string|\DateInterval|null $precision 958 * 959 * @return CarbonInterface 960 */ 961 public function ceil($precision = 1); 962 963 /** 964 * Ceil the current instance at the given unit with given precision if specified. 965 * 966 * @param string $unit 967 * @param float|int $precision 968 * 969 * @return CarbonInterface 970 */ 971 public function ceilUnit($unit, $precision = 1); 972 973 /** 974 * Ceil the current instance week. 975 * 976 * @param int $weekStartsAt optional start allow you to specify the day of week to use to start the week 977 * 978 * @return CarbonInterface 979 */ 980 public function ceilWeek($weekStartsAt = null); 981 982 /** 983 * Similar to native modify() method of DateTime but can handle more grammars. 984 * 985 * @example 986 * ``` 987 * echo Carbon::now()->change('next 2pm'); 988 * ``` 989 * 990 * @link https://php.net/manual/en/datetime.modify.php 991 * 992 * @param string $modifier 993 * 994 * @return static 995 */ 996 public function change($modifier); 997 998 /** 999 * Cleanup properties attached to the public scope of DateTime when a dump of the date is requested. 1000 * foreach ($date as $_) {} 1001 * serializer($date) 1002 * var_export($date) 1003 * get_object_vars($date) 1004 */ 1005 public function cleanupDumpProperties(); 1006 1007 /** 1008 * @alias copy 1009 * 1010 * Get a copy of the instance. 1011 * 1012 * @return static 1013 */ 1014 public function clone(); 1015 1016 /** 1017 * Get the closest date from the instance (second-precision). 1018 * 1019 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date1 1020 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date2 1021 * 1022 * @return static 1023 */ 1024 public function closest($date1, $date2); 1025 1026 /** 1027 * Get a copy of the instance. 1028 * 1029 * @return static 1030 */ 1031 public function copy(); 1032 1033 /** 1034 * Create a new Carbon instance from a specific date and time. 1035 * 1036 * If any of $year, $month or $day are set to null their now() values will 1037 * be used. 1038 * 1039 * If $hour is null it will be set to its now() value and the default 1040 * values for $minute and $second will be their now() values. 1041 * 1042 * If $hour is not null then the default values for $minute and $second 1043 * will be 0. 1044 * 1045 * @param int|null $year 1046 * @param int|null $month 1047 * @param int|null $day 1048 * @param int|null $hour 1049 * @param int|null $minute 1050 * @param int|null $second 1051 * @param DateTimeZone|string|null $tz 1052 * 1053 * @throws InvalidFormatException 1054 * 1055 * @return static|false 1056 */ 1057 public static function create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null); 1058 1059 /** 1060 * Create a Carbon instance from just a date. The time portion is set to now. 1061 * 1062 * @param int|null $year 1063 * @param int|null $month 1064 * @param int|null $day 1065 * @param DateTimeZone|string|null $tz 1066 * 1067 * @throws InvalidFormatException 1068 * 1069 * @return static 1070 */ 1071 public static function createFromDate($year = null, $month = null, $day = null, $tz = null); 1072 1073 /** 1074 * Create a Carbon instance from a specific format. 1075 * 1076 * @param string $format Datetime format 1077 * @param string $time 1078 * @param DateTimeZone|string|false|null $tz 1079 * 1080 * @throws InvalidFormatException 1081 * 1082 * @return static|false 1083 */ 1084 #[ReturnTypeWillChange] 1085 public static function createFromFormat($format, $time, $tz = null); 1086 1087 /** 1088 * Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()). 1089 * 1090 * @param string $format Datetime format 1091 * @param string $time 1092 * @param DateTimeZone|string|false|null $tz optional timezone 1093 * @param string|null $locale locale to be used for LTS, LT, LL, LLL, etc. macro-formats (en by fault, unneeded if no such macro-format in use) 1094 * @param \Symfony\Component\Translation\TranslatorInterface $translator optional custom translator to use for macro-formats 1095 * 1096 * @throws InvalidFormatException 1097 * 1098 * @return static|false 1099 */ 1100 public static function createFromIsoFormat($format, $time, $tz = null, $locale = 'en', $translator = null); 1101 1102 /** 1103 * Create a Carbon instance from a specific format and a string in a given language. 1104 * 1105 * @param string $format Datetime format 1106 * @param string $locale 1107 * @param string $time 1108 * @param DateTimeZone|string|false|null $tz 1109 * 1110 * @throws InvalidFormatException 1111 * 1112 * @return static|false 1113 */ 1114 public static function createFromLocaleFormat($format, $locale, $time, $tz = null); 1115 1116 /** 1117 * Create a Carbon instance from a specific ISO format and a string in a given language. 1118 * 1119 * @param string $format Datetime ISO format 1120 * @param string $locale 1121 * @param string $time 1122 * @param DateTimeZone|string|false|null $tz 1123 * 1124 * @throws InvalidFormatException 1125 * 1126 * @return static|false 1127 */ 1128 public static function createFromLocaleIsoFormat($format, $locale, $time, $tz = null); 1129 1130 /** 1131 * Create a Carbon instance from just a time. The date portion is set to today. 1132 * 1133 * @param int|null $hour 1134 * @param int|null $minute 1135 * @param int|null $second 1136 * @param DateTimeZone|string|null $tz 1137 * 1138 * @throws InvalidFormatException 1139 * 1140 * @return static 1141 */ 1142 public static function createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null); 1143 1144 /** 1145 * Create a Carbon instance from a time string. The date portion is set to today. 1146 * 1147 * @param string $time 1148 * @param DateTimeZone|string|null $tz 1149 * 1150 * @throws InvalidFormatException 1151 * 1152 * @return static 1153 */ 1154 public static function createFromTimeString($time, $tz = null); 1155 1156 /** 1157 * Create a Carbon instance from a timestamp and set the timezone (use default one if not specified). 1158 * 1159 * Timestamp input can be given as int, float or a string containing one or more numbers. 1160 * 1161 * @param float|int|string $timestamp 1162 * @param \DateTimeZone|string|null $tz 1163 * 1164 * @return static 1165 */ 1166 public static function createFromTimestamp($timestamp, $tz = null); 1167 1168 /** 1169 * Create a Carbon instance from a timestamp in milliseconds. 1170 * 1171 * Timestamp input can be given as int, float or a string containing one or more numbers. 1172 * 1173 * @param float|int|string $timestamp 1174 * @param \DateTimeZone|string|null $tz 1175 * 1176 * @return static 1177 */ 1178 public static function createFromTimestampMs($timestamp, $tz = null); 1179 1180 /** 1181 * Create a Carbon instance from a timestamp in milliseconds. 1182 * 1183 * Timestamp input can be given as int, float or a string containing one or more numbers. 1184 * 1185 * @param float|int|string $timestamp 1186 * 1187 * @return static 1188 */ 1189 public static function createFromTimestampMsUTC($timestamp); 1190 1191 /** 1192 * Create a Carbon instance from an timestamp keeping the timezone to UTC. 1193 * 1194 * Timestamp input can be given as int, float or a string containing one or more numbers. 1195 * 1196 * @param float|int|string $timestamp 1197 * 1198 * @return static 1199 */ 1200 public static function createFromTimestampUTC($timestamp); 1201 1202 /** 1203 * Create a Carbon instance from just a date. The time portion is set to midnight. 1204 * 1205 * @param int|null $year 1206 * @param int|null $month 1207 * @param int|null $day 1208 * @param DateTimeZone|string|null $tz 1209 * 1210 * @throws InvalidFormatException 1211 * 1212 * @return static 1213 */ 1214 public static function createMidnightDate($year = null, $month = null, $day = null, $tz = null); 1215 1216 /** 1217 * Create a new safe Carbon instance from a specific date and time. 1218 * 1219 * If any of $year, $month or $day are set to null their now() values will 1220 * be used. 1221 * 1222 * If $hour is null it will be set to its now() value and the default 1223 * values for $minute and $second will be their now() values. 1224 * 1225 * If $hour is not null then the default values for $minute and $second 1226 * will be 0. 1227 * 1228 * If one of the set values is not valid, an InvalidDateException 1229 * will be thrown. 1230 * 1231 * @param int|null $year 1232 * @param int|null $month 1233 * @param int|null $day 1234 * @param int|null $hour 1235 * @param int|null $minute 1236 * @param int|null $second 1237 * @param DateTimeZone|string|null $tz 1238 * 1239 * @throws InvalidDateException 1240 * 1241 * @return static|false 1242 */ 1243 public static function createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null); 1244 1245 /** 1246 * Create a new Carbon instance from a specific date and time using strict validation. 1247 * 1248 * @see create() 1249 * 1250 * @param int|null $year 1251 * @param int|null $month 1252 * @param int|null $day 1253 * @param int|null $hour 1254 * @param int|null $minute 1255 * @param int|null $second 1256 * @param DateTimeZone|string|null $tz 1257 * 1258 * @throws InvalidFormatException 1259 * 1260 * @return static 1261 */ 1262 public static function createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null); 1263 1264 /** 1265 * Get/set the day of year. 1266 * 1267 * @param int|null $value new value for day of year if using as setter. 1268 * 1269 * @return static|int 1270 */ 1271 public function dayOfYear($value = null); 1272 1273 /** 1274 * Get the difference as a CarbonInterval instance. 1275 * Return absolute interval (always positive) unless you pass false to the second argument. 1276 * 1277 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1278 * @param bool $absolute Get the absolute of the difference 1279 * 1280 * @return CarbonInterval 1281 */ 1282 public function diffAsCarbonInterval($date = null, $absolute = true); 1283 1284 /** 1285 * Get the difference by the given interval using a filter closure. 1286 * 1287 * @param CarbonInterval $ci An interval to traverse by 1288 * @param Closure $callback 1289 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1290 * @param bool $absolute Get the absolute of the difference 1291 * 1292 * @return int 1293 */ 1294 public function diffFiltered(CarbonInterval $ci, Closure $callback, $date = null, $absolute = true); 1295 1296 /** 1297 * Get the difference in a human readable format in the current locale from current instance to an other 1298 * instance given (or now if null given). 1299 * 1300 * @example 1301 * ``` 1302 * echo Carbon::tomorrow()->diffForHumans() . "\n"; 1303 * echo Carbon::tomorrow()->diffForHumans(['parts' => 2]) . "\n"; 1304 * echo Carbon::tomorrow()->diffForHumans(['parts' => 3, 'join' => true]) . "\n"; 1305 * echo Carbon::tomorrow()->diffForHumans(Carbon::yesterday()) . "\n"; 1306 * echo Carbon::tomorrow()->diffForHumans(Carbon::yesterday(), ['short' => true]) . "\n"; 1307 * ``` 1308 * 1309 * @param Carbon|\DateTimeInterface|string|array|null $other if array passed, will be used as parameters array, see $syntax below; 1310 * if null passed, now will be used as comparison reference; 1311 * if any other type, it will be converted to date and used as reference. 1312 * @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains: 1313 * - 'syntax' entry (see below) 1314 * - 'short' entry (see below) 1315 * - 'parts' entry (see below) 1316 * - 'options' entry (see below) 1317 * - 'join' entry determines how to join multiple parts of the string 1318 * ` - if $join is a string, it's used as a joiner glue 1319 * ` - if $join is a callable/closure, it get the list of string and should return a string 1320 * ` - if $join is an array, the first item will be the default glue, and the second item 1321 * ` will be used instead of the glue for the last item 1322 * ` - if $join is true, it will be guessed from the locale ('list' translation file entry) 1323 * ` - if $join is missing, a space will be used as glue 1324 * - 'other' entry (see above) 1325 * if int passed, it add modifiers: 1326 * Possible values: 1327 * - CarbonInterface::DIFF_ABSOLUTE no modifiers 1328 * - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier 1329 * - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier 1330 * Default value: CarbonInterface::DIFF_ABSOLUTE 1331 * @param bool $short displays short format of time units 1332 * @param int $parts maximum number of parts to display (default value: 1: single unit) 1333 * @param int $options human diff options 1334 * 1335 * @return string 1336 */ 1337 public function diffForHumans($other = null, $syntax = null, $short = false, $parts = 1, $options = null); 1338 1339 /** 1340 * Get the difference in days rounded down. 1341 * 1342 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1343 * @param bool $absolute Get the absolute of the difference 1344 * 1345 * @return int 1346 */ 1347 public function diffInDays($date = null, $absolute = true); 1348 1349 /** 1350 * Get the difference in days using a filter closure rounded down. 1351 * 1352 * @param Closure $callback 1353 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1354 * @param bool $absolute Get the absolute of the difference 1355 * 1356 * @return int 1357 */ 1358 public function diffInDaysFiltered(Closure $callback, $date = null, $absolute = true); 1359 1360 /** 1361 * Get the difference in hours rounded down. 1362 * 1363 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1364 * @param bool $absolute Get the absolute of the difference 1365 * 1366 * @return int 1367 */ 1368 public function diffInHours($date = null, $absolute = true); 1369 1370 /** 1371 * Get the difference in hours using a filter closure rounded down. 1372 * 1373 * @param Closure $callback 1374 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1375 * @param bool $absolute Get the absolute of the difference 1376 * 1377 * @return int 1378 */ 1379 public function diffInHoursFiltered(Closure $callback, $date = null, $absolute = true); 1380 1381 /** 1382 * Get the difference in microseconds. 1383 * 1384 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1385 * @param bool $absolute Get the absolute of the difference 1386 * 1387 * @return int 1388 */ 1389 public function diffInMicroseconds($date = null, $absolute = true); 1390 1391 /** 1392 * Get the difference in milliseconds rounded down. 1393 * 1394 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1395 * @param bool $absolute Get the absolute of the difference 1396 * 1397 * @return int 1398 */ 1399 public function diffInMilliseconds($date = null, $absolute = true); 1400 1401 /** 1402 * Get the difference in minutes rounded down. 1403 * 1404 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1405 * @param bool $absolute Get the absolute of the difference 1406 * 1407 * @return int 1408 */ 1409 public function diffInMinutes($date = null, $absolute = true); 1410 1411 /** 1412 * Get the difference in months rounded down. 1413 * 1414 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1415 * @param bool $absolute Get the absolute of the difference 1416 * 1417 * @return int 1418 */ 1419 public function diffInMonths($date = null, $absolute = true); 1420 1421 /** 1422 * Get the difference in quarters rounded down. 1423 * 1424 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1425 * @param bool $absolute Get the absolute of the difference 1426 * 1427 * @return int 1428 */ 1429 public function diffInQuarters($date = null, $absolute = true); 1430 1431 /** 1432 * Get the difference in hours rounded down using timestamps. 1433 * 1434 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1435 * @param bool $absolute Get the absolute of the difference 1436 * 1437 * @return int 1438 */ 1439 public function diffInRealHours($date = null, $absolute = true); 1440 1441 /** 1442 * Get the difference in microseconds using timestamps. 1443 * 1444 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1445 * @param bool $absolute Get the absolute of the difference 1446 * 1447 * @return int 1448 */ 1449 public function diffInRealMicroseconds($date = null, $absolute = true); 1450 1451 /** 1452 * Get the difference in milliseconds rounded down using timestamps. 1453 * 1454 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1455 * @param bool $absolute Get the absolute of the difference 1456 * 1457 * @return int 1458 */ 1459 public function diffInRealMilliseconds($date = null, $absolute = true); 1460 1461 /** 1462 * Get the difference in minutes rounded down using timestamps. 1463 * 1464 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1465 * @param bool $absolute Get the absolute of the difference 1466 * 1467 * @return int 1468 */ 1469 public function diffInRealMinutes($date = null, $absolute = true); 1470 1471 /** 1472 * Get the difference in seconds using timestamps. 1473 * 1474 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1475 * @param bool $absolute Get the absolute of the difference 1476 * 1477 * @return int 1478 */ 1479 public function diffInRealSeconds($date = null, $absolute = true); 1480 1481 /** 1482 * Get the difference in seconds rounded down. 1483 * 1484 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1485 * @param bool $absolute Get the absolute of the difference 1486 * 1487 * @return int 1488 */ 1489 public function diffInSeconds($date = null, $absolute = true); 1490 1491 /** 1492 * Get the difference in weekdays rounded down. 1493 * 1494 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1495 * @param bool $absolute Get the absolute of the difference 1496 * 1497 * @return int 1498 */ 1499 public function diffInWeekdays($date = null, $absolute = true); 1500 1501 /** 1502 * Get the difference in weekend days using a filter rounded down. 1503 * 1504 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1505 * @param bool $absolute Get the absolute of the difference 1506 * 1507 * @return int 1508 */ 1509 public function diffInWeekendDays($date = null, $absolute = true); 1510 1511 /** 1512 * Get the difference in weeks rounded down. 1513 * 1514 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1515 * @param bool $absolute Get the absolute of the difference 1516 * 1517 * @return int 1518 */ 1519 public function diffInWeeks($date = null, $absolute = true); 1520 1521 /** 1522 * Get the difference in years 1523 * 1524 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1525 * @param bool $absolute Get the absolute of the difference 1526 * 1527 * @return int 1528 */ 1529 public function diffInYears($date = null, $absolute = true); 1530 1531 /** 1532 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 1533 * You should rather use the ->settings() method. 1534 * @see settings 1535 * 1536 * @param int $humanDiffOption 1537 */ 1538 public static function disableHumanDiffOption($humanDiffOption); 1539 1540 /** 1541 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 1542 * You should rather use the ->settings() method. 1543 * @see settings 1544 * 1545 * @param int $humanDiffOption 1546 */ 1547 public static function enableHumanDiffOption($humanDiffOption); 1548 1549 /** 1550 * Modify to end of current given unit. 1551 * 1552 * @example 1553 * ``` 1554 * echo Carbon::parse('2018-07-25 12:45:16.334455') 1555 * ->startOf('month') 1556 * ->endOf('week', Carbon::FRIDAY); 1557 * ``` 1558 * 1559 * @param string $unit 1560 * @param array<int, mixed> $params 1561 * 1562 * @return static 1563 */ 1564 public function endOf($unit, ...$params); 1565 1566 /** 1567 * Resets the date to end of the century and time to 23:59:59.999999 1568 * 1569 * @example 1570 * ``` 1571 * echo Carbon::parse('2018-07-25 12:45:16')->endOfCentury(); 1572 * ``` 1573 * 1574 * @return static 1575 */ 1576 public function endOfCentury(); 1577 1578 /** 1579 * Resets the time to 23:59:59.999999 end of day 1580 * 1581 * @example 1582 * ``` 1583 * echo Carbon::parse('2018-07-25 12:45:16')->endOfDay(); 1584 * ``` 1585 * 1586 * @return static 1587 */ 1588 public function endOfDay(); 1589 1590 /** 1591 * Resets the date to end of the decade and time to 23:59:59.999999 1592 * 1593 * @example 1594 * ``` 1595 * echo Carbon::parse('2018-07-25 12:45:16')->endOfDecade(); 1596 * ``` 1597 * 1598 * @return static 1599 */ 1600 public function endOfDecade(); 1601 1602 /** 1603 * Modify to end of current hour, minutes and seconds become 59 1604 * 1605 * @example 1606 * ``` 1607 * echo Carbon::parse('2018-07-25 12:45:16')->endOfHour(); 1608 * ``` 1609 * 1610 * @return static 1611 */ 1612 public function endOfHour(); 1613 1614 /** 1615 * Resets the date to end of the millennium and time to 23:59:59.999999 1616 * 1617 * @example 1618 * ``` 1619 * echo Carbon::parse('2018-07-25 12:45:16')->endOfMillennium(); 1620 * ``` 1621 * 1622 * @return static 1623 */ 1624 public function endOfMillennium(); 1625 1626 /** 1627 * Modify to end of current minute, seconds become 59 1628 * 1629 * @example 1630 * ``` 1631 * echo Carbon::parse('2018-07-25 12:45:16')->endOfMinute(); 1632 * ``` 1633 * 1634 * @return static 1635 */ 1636 public function endOfMinute(); 1637 1638 /** 1639 * Resets the date to end of the month and time to 23:59:59.999999 1640 * 1641 * @example 1642 * ``` 1643 * echo Carbon::parse('2018-07-25 12:45:16')->endOfMonth(); 1644 * ``` 1645 * 1646 * @return static 1647 */ 1648 public function endOfMonth(); 1649 1650 /** 1651 * Resets the date to end of the quarter and time to 23:59:59.999999 1652 * 1653 * @example 1654 * ``` 1655 * echo Carbon::parse('2018-07-25 12:45:16')->endOfQuarter(); 1656 * ``` 1657 * 1658 * @return static 1659 */ 1660 public function endOfQuarter(); 1661 1662 /** 1663 * Modify to end of current second, microseconds become 999999 1664 * 1665 * @example 1666 * ``` 1667 * echo Carbon::parse('2018-07-25 12:45:16.334455') 1668 * ->endOfSecond() 1669 * ->format('H:i:s.u'); 1670 * ``` 1671 * 1672 * @return static 1673 */ 1674 public function endOfSecond(); 1675 1676 /** 1677 * Resets the date to end of week (defined in $weekEndsAt) and time to 23:59:59.999999 1678 * 1679 * @example 1680 * ``` 1681 * echo Carbon::parse('2018-07-25 12:45:16')->endOfWeek() . "\n"; 1682 * echo Carbon::parse('2018-07-25 12:45:16')->locale('ar')->endOfWeek() . "\n"; 1683 * echo Carbon::parse('2018-07-25 12:45:16')->endOfWeek(Carbon::SATURDAY) . "\n"; 1684 * ``` 1685 * 1686 * @param int $weekEndsAt optional start allow you to specify the day of week to use to end the week 1687 * 1688 * @return static 1689 */ 1690 public function endOfWeek($weekEndsAt = null); 1691 1692 /** 1693 * Resets the date to end of the year and time to 23:59:59.999999 1694 * 1695 * @example 1696 * ``` 1697 * echo Carbon::parse('2018-07-25 12:45:16')->endOfYear(); 1698 * ``` 1699 * 1700 * @return static 1701 */ 1702 public function endOfYear(); 1703 1704 /** 1705 * Determines if the instance is equal to another 1706 * 1707 * @example 1708 * ``` 1709 * Carbon::parse('2018-07-25 12:45:16')->eq('2018-07-25 12:45:16'); // true 1710 * Carbon::parse('2018-07-25 12:45:16')->eq(Carbon::parse('2018-07-25 12:45:16')); // true 1711 * Carbon::parse('2018-07-25 12:45:16')->eq('2018-07-25 12:45:17'); // false 1712 * ``` 1713 * 1714 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 1715 * 1716 * @see equalTo() 1717 * 1718 * @return bool 1719 */ 1720 public function eq($date): bool; 1721 1722 /** 1723 * Determines if the instance is equal to another 1724 * 1725 * @example 1726 * ``` 1727 * Carbon::parse('2018-07-25 12:45:16')->equalTo('2018-07-25 12:45:16'); // true 1728 * Carbon::parse('2018-07-25 12:45:16')->equalTo(Carbon::parse('2018-07-25 12:45:16')); // true 1729 * Carbon::parse('2018-07-25 12:45:16')->equalTo('2018-07-25 12:45:17'); // false 1730 * ``` 1731 * 1732 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 1733 * 1734 * @return bool 1735 */ 1736 public function equalTo($date): bool; 1737 1738 /** 1739 * Set the current locale to the given, execute the passed function, reset the locale to previous one, 1740 * then return the result of the closure (or null if the closure was void). 1741 * 1742 * @param string $locale locale ex. en 1743 * @param callable $func 1744 * 1745 * @return mixed 1746 */ 1747 public static function executeWithLocale($locale, $func); 1748 1749 /** 1750 * Get the farthest date from the instance (second-precision). 1751 * 1752 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date1 1753 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date2 1754 * 1755 * @return static 1756 */ 1757 public function farthest($date1, $date2); 1758 1759 /** 1760 * Modify to the first occurrence of a given day of the week 1761 * in the current month. If no dayOfWeek is provided, modify to the 1762 * first day of the current month. Use the supplied constants 1763 * to indicate the desired dayOfWeek, ex. static::MONDAY. 1764 * 1765 * @param int|null $dayOfWeek 1766 * 1767 * @return static 1768 */ 1769 public function firstOfMonth($dayOfWeek = null); 1770 1771 /** 1772 * Modify to the first occurrence of a given day of the week 1773 * in the current quarter. If no dayOfWeek is provided, modify to the 1774 * first day of the current quarter. Use the supplied constants 1775 * to indicate the desired dayOfWeek, ex. static::MONDAY. 1776 * 1777 * @param int|null $dayOfWeek day of the week default null 1778 * 1779 * @return static 1780 */ 1781 public function firstOfQuarter($dayOfWeek = null); 1782 1783 /** 1784 * Modify to the first occurrence of a given day of the week 1785 * in the current year. If no dayOfWeek is provided, modify to the 1786 * first day of the current year. Use the supplied constants 1787 * to indicate the desired dayOfWeek, ex. static::MONDAY. 1788 * 1789 * @param int|null $dayOfWeek day of the week default null 1790 * 1791 * @return static 1792 */ 1793 public function firstOfYear($dayOfWeek = null); 1794 1795 /** 1796 * Get the difference in days as float (microsecond-precision). 1797 * 1798 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1799 * @param bool $absolute Get the absolute of the difference 1800 * 1801 * @return float 1802 */ 1803 public function floatDiffInDays($date = null, $absolute = true); 1804 1805 /** 1806 * Get the difference in hours as float (microsecond-precision). 1807 * 1808 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1809 * @param bool $absolute Get the absolute of the difference 1810 * 1811 * @return float 1812 */ 1813 public function floatDiffInHours($date = null, $absolute = true); 1814 1815 /** 1816 * Get the difference in minutes as float (microsecond-precision). 1817 * 1818 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1819 * @param bool $absolute Get the absolute of the difference 1820 * 1821 * @return float 1822 */ 1823 public function floatDiffInMinutes($date = null, $absolute = true); 1824 1825 /** 1826 * Get the difference in months as float (microsecond-precision). 1827 * 1828 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1829 * @param bool $absolute Get the absolute of the difference 1830 * 1831 * @return float 1832 */ 1833 public function floatDiffInMonths($date = null, $absolute = true); 1834 1835 /** 1836 * Get the difference in days as float (microsecond-precision). 1837 * 1838 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1839 * @param bool $absolute Get the absolute of the difference 1840 * 1841 * @return float 1842 */ 1843 public function floatDiffInRealDays($date = null, $absolute = true); 1844 1845 /** 1846 * Get the difference in hours as float (microsecond-precision) using timestamps. 1847 * 1848 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1849 * @param bool $absolute Get the absolute of the difference 1850 * 1851 * @return float 1852 */ 1853 public function floatDiffInRealHours($date = null, $absolute = true); 1854 1855 /** 1856 * Get the difference in minutes as float (microsecond-precision) using timestamps. 1857 * 1858 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1859 * @param bool $absolute Get the absolute of the difference 1860 * 1861 * @return float 1862 */ 1863 public function floatDiffInRealMinutes($date = null, $absolute = true); 1864 1865 /** 1866 * Get the difference in months as float (microsecond-precision) using timestamps. 1867 * 1868 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1869 * @param bool $absolute Get the absolute of the difference 1870 * 1871 * @return float 1872 */ 1873 public function floatDiffInRealMonths($date = null, $absolute = true); 1874 1875 /** 1876 * Get the difference in seconds as float (microsecond-precision) using timestamps. 1877 * 1878 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1879 * @param bool $absolute Get the absolute of the difference 1880 * 1881 * @return float 1882 */ 1883 public function floatDiffInRealSeconds($date = null, $absolute = true); 1884 1885 /** 1886 * Get the difference in weeks as float (microsecond-precision). 1887 * 1888 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1889 * @param bool $absolute Get the absolute of the difference 1890 * 1891 * @return float 1892 */ 1893 public function floatDiffInRealWeeks($date = null, $absolute = true); 1894 1895 /** 1896 * Get the difference in year as float (microsecond-precision) using timestamps. 1897 * 1898 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1899 * @param bool $absolute Get the absolute of the difference 1900 * 1901 * @return float 1902 */ 1903 public function floatDiffInRealYears($date = null, $absolute = true); 1904 1905 /** 1906 * Get the difference in seconds as float (microsecond-precision). 1907 * 1908 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1909 * @param bool $absolute Get the absolute of the difference 1910 * 1911 * @return float 1912 */ 1913 public function floatDiffInSeconds($date = null, $absolute = true); 1914 1915 /** 1916 * Get the difference in weeks as float (microsecond-precision). 1917 * 1918 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1919 * @param bool $absolute Get the absolute of the difference 1920 * 1921 * @return float 1922 */ 1923 public function floatDiffInWeeks($date = null, $absolute = true); 1924 1925 /** 1926 * Get the difference in year as float (microsecond-precision). 1927 * 1928 * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date 1929 * @param bool $absolute Get the absolute of the difference 1930 * 1931 * @return float 1932 */ 1933 public function floatDiffInYears($date = null, $absolute = true); 1934 1935 /** 1936 * Round the current instance second with given precision if specified. 1937 * 1938 * @param float|int|string|\DateInterval|null $precision 1939 * 1940 * @return CarbonInterface 1941 */ 1942 public function floor($precision = 1); 1943 1944 /** 1945 * Truncate the current instance at the given unit with given precision if specified. 1946 * 1947 * @param string $unit 1948 * @param float|int $precision 1949 * 1950 * @return CarbonInterface 1951 */ 1952 public function floorUnit($unit, $precision = 1); 1953 1954 /** 1955 * Truncate the current instance week. 1956 * 1957 * @param int $weekStartsAt optional start allow you to specify the day of week to use to start the week 1958 * 1959 * @return CarbonInterface 1960 */ 1961 public function floorWeek($weekStartsAt = null); 1962 1963 /** 1964 * Format the instance with the current locale. You can set the current 1965 * locale using setlocale() https://php.net/setlocale. 1966 * 1967 * @param string $format 1968 * 1969 * @return string 1970 */ 1971 public function formatLocalized($format); 1972 1973 /** 1974 * @alias diffForHumans 1975 * 1976 * Get the difference in a human readable format in the current locale from current instance to an other 1977 * instance given (or now if null given). 1978 * 1979 * @param Carbon|\DateTimeInterface|string|array|null $other if array passed, will be used as parameters array, see $syntax below; 1980 * if null passed, now will be used as comparison reference; 1981 * if any other type, it will be converted to date and used as reference. 1982 * @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains: 1983 * - 'syntax' entry (see below) 1984 * - 'short' entry (see below) 1985 * - 'parts' entry (see below) 1986 * - 'options' entry (see below) 1987 * - 'join' entry determines how to join multiple parts of the string 1988 * ` - if $join is a string, it's used as a joiner glue 1989 * ` - if $join is a callable/closure, it get the list of string and should return a string 1990 * ` - if $join is an array, the first item will be the default glue, and the second item 1991 * ` will be used instead of the glue for the last item 1992 * ` - if $join is true, it will be guessed from the locale ('list' translation file entry) 1993 * ` - if $join is missing, a space will be used as glue 1994 * - 'other' entry (see above) 1995 * if int passed, it add modifiers: 1996 * Possible values: 1997 * - CarbonInterface::DIFF_ABSOLUTE no modifiers 1998 * - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier 1999 * - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier 2000 * Default value: CarbonInterface::DIFF_ABSOLUTE 2001 * @param bool $short displays short format of time units 2002 * @param int $parts maximum number of parts to display (default value: 1: single unit) 2003 * @param int $options human diff options 2004 * 2005 * @return string 2006 */ 2007 public function from($other = null, $syntax = null, $short = false, $parts = 1, $options = null); 2008 2009 /** 2010 * Get the difference in a human readable format in the current locale from current 2011 * instance to now. 2012 * 2013 * @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains: 2014 * - 'syntax' entry (see below) 2015 * - 'short' entry (see below) 2016 * - 'parts' entry (see below) 2017 * - 'options' entry (see below) 2018 * - 'join' entry determines how to join multiple parts of the string 2019 * ` - if $join is a string, it's used as a joiner glue 2020 * ` - if $join is a callable/closure, it get the list of string and should return a string 2021 * ` - if $join is an array, the first item will be the default glue, and the second item 2022 * ` will be used instead of the glue for the last item 2023 * ` - if $join is true, it will be guessed from the locale ('list' translation file entry) 2024 * ` - if $join is missing, a space will be used as glue 2025 * if int passed, it add modifiers: 2026 * Possible values: 2027 * - CarbonInterface::DIFF_ABSOLUTE no modifiers 2028 * - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier 2029 * - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier 2030 * Default value: CarbonInterface::DIFF_ABSOLUTE 2031 * @param bool $short displays short format of time units 2032 * @param int $parts maximum number of parts to display (default value: 1: single unit) 2033 * @param int $options human diff options 2034 * 2035 * @return string 2036 */ 2037 public function fromNow($syntax = null, $short = false, $parts = 1, $options = null); 2038 2039 /** 2040 * Create an instance from a serialized string. 2041 * 2042 * @param string $value 2043 * 2044 * @throws InvalidFormatException 2045 * 2046 * @return static 2047 */ 2048 public static function fromSerialized($value); 2049 2050 /** 2051 * Register a custom macro. 2052 * 2053 * @param object|callable $macro 2054 * @param int $priority marco with higher priority is tried first 2055 * 2056 * @return void 2057 */ 2058 public static function genericMacro($macro, $priority = 0); 2059 2060 /** 2061 * Get a part of the Carbon object 2062 * 2063 * @param string $name 2064 * 2065 * @throws UnknownGetterException 2066 * 2067 * @return string|int|bool|DateTimeZone|null 2068 */ 2069 public function get($name); 2070 2071 /** 2072 * Returns the alternative number for a given date property if available in the current locale. 2073 * 2074 * @param string $key date property 2075 * 2076 * @return string 2077 */ 2078 public function getAltNumber(string $key): string; 2079 2080 /** 2081 * Returns the list of internally available locales and already loaded custom locales. 2082 * (It will ignore custom translator dynamic loading.) 2083 * 2084 * @return array 2085 */ 2086 public static function getAvailableLocales(); 2087 2088 /** 2089 * Returns list of Language object for each available locale. This object allow you to get the ISO name, native 2090 * name, region and variant of the locale. 2091 * 2092 * @return Language[] 2093 */ 2094 public static function getAvailableLocalesInfo(); 2095 2096 /** 2097 * Returns list of calendar formats for ISO formatting. 2098 * 2099 * @param string|null $locale current locale used if null 2100 * 2101 * @return array 2102 */ 2103 public function getCalendarFormats($locale = null); 2104 2105 /** 2106 * Get the days of the week 2107 * 2108 * @return array 2109 */ 2110 public static function getDays(); 2111 2112 /** 2113 * Get the fallback locale. 2114 * 2115 * @see https://symfony.com/doc/current/components/translation.html#fallback-locales 2116 * 2117 * @return string|null 2118 */ 2119 public static function getFallbackLocale(); 2120 2121 /** 2122 * List of replacements from date() format to isoFormat(). 2123 * 2124 * @return array 2125 */ 2126 public static function getFormatsToIsoReplacements(); 2127 2128 /** 2129 * Return default humanDiff() options (merged flags as integer). 2130 * 2131 * @return int 2132 */ 2133 public static function getHumanDiffOptions(); 2134 2135 /** 2136 * Returns list of locale formats for ISO formatting. 2137 * 2138 * @param string|null $locale current locale used if null 2139 * 2140 * @return array 2141 */ 2142 public function getIsoFormats($locale = null); 2143 2144 /** 2145 * Returns list of locale units for ISO formatting. 2146 * 2147 * @return array 2148 */ 2149 public static function getIsoUnits(); 2150 2151 /** 2152 * {@inheritdoc} 2153 * 2154 * @return array 2155 */ 2156 #[ReturnTypeWillChange] 2157 public static function getLastErrors(); 2158 2159 /** 2160 * Get the raw callable macro registered globally or locally for a given name. 2161 * 2162 * @param string $name 2163 * 2164 * @return callable|null 2165 */ 2166 public function getLocalMacro($name); 2167 2168 /** 2169 * Get the translator of the current instance or the default if none set. 2170 * 2171 * @return \Symfony\Component\Translation\TranslatorInterface 2172 */ 2173 public function getLocalTranslator(); 2174 2175 /** 2176 * Get the current translator locale. 2177 * 2178 * @return string 2179 */ 2180 public static function getLocale(); 2181 2182 /** 2183 * Get the raw callable macro registered globally for a given name. 2184 * 2185 * @param string $name 2186 * 2187 * @return callable|null 2188 */ 2189 public static function getMacro($name); 2190 2191 /** 2192 * get midday/noon hour 2193 * 2194 * @return int 2195 */ 2196 public static function getMidDayAt(); 2197 2198 /** 2199 * Returns the offset hour and minute formatted with +/- and a given separator (":" by default). 2200 * For example, if the time zone is 9 hours 30 minutes, you'll get "+09:30", with "@@" as first 2201 * argument, "+09@@30", with "" as first argument, "+0930". Negative offset will return something 2202 * like "-12:00". 2203 * 2204 * @param string $separator string to place between hours and minutes (":" by default) 2205 * 2206 * @return string 2207 */ 2208 public function getOffsetString($separator = ':'); 2209 2210 /** 2211 * Returns a unit of the instance padded with 0 by default or any other string if specified. 2212 * 2213 * @param string $unit Carbon unit name 2214 * @param int $length Length of the output (2 by default) 2215 * @param string $padString String to use for padding ("0" by default) 2216 * @param int $padType Side(s) to pad (STR_PAD_LEFT by default) 2217 * 2218 * @return string 2219 */ 2220 public function getPaddedUnit($unit, $length = 2, $padString = '0', $padType = 0); 2221 2222 /** 2223 * Returns a timestamp rounded with the given precision (6 by default). 2224 * 2225 * @example getPreciseTimestamp() 1532087464437474 (microsecond maximum precision) 2226 * @example getPreciseTimestamp(6) 1532087464437474 2227 * @example getPreciseTimestamp(5) 153208746443747 (1/100000 second precision) 2228 * @example getPreciseTimestamp(4) 15320874644375 (1/10000 second precision) 2229 * @example getPreciseTimestamp(3) 1532087464437 (millisecond precision) 2230 * @example getPreciseTimestamp(2) 153208746444 (1/100 second precision) 2231 * @example getPreciseTimestamp(1) 15320874644 (1/10 second precision) 2232 * @example getPreciseTimestamp(0) 1532087464 (second precision) 2233 * @example getPreciseTimestamp(-1) 153208746 (10 second precision) 2234 * @example getPreciseTimestamp(-2) 15320875 (100 second precision) 2235 * 2236 * @param int $precision 2237 * 2238 * @return float 2239 */ 2240 public function getPreciseTimestamp($precision = 6); 2241 2242 /** 2243 * Returns current local settings. 2244 * 2245 * @return array 2246 */ 2247 public function getSettings(); 2248 2249 /** 2250 * Get the Carbon instance (real or mock) to be returned when a "now" 2251 * instance is created. 2252 * 2253 * @return Closure|static the current instance used for testing 2254 */ 2255 public static function getTestNow(); 2256 2257 /** 2258 * Return a format from H:i to H:i:s.u according to given unit precision. 2259 * 2260 * @param string $unitPrecision "minute", "second", "millisecond" or "microsecond" 2261 * 2262 * @return string 2263 */ 2264 public static function getTimeFormatByPrecision($unitPrecision); 2265 2266 /** 2267 * Returns the timestamp with millisecond precision. 2268 * 2269 * @return int 2270 */ 2271 public function getTimestampMs(); 2272 2273 /** 2274 * Get the translation of the current week day name (with context for languages with multiple forms). 2275 * 2276 * @param string|null $context whole format string 2277 * @param string $keySuffix "", "_short" or "_min" 2278 * @param string|null $defaultValue default value if translation missing 2279 * 2280 * @return string 2281 */ 2282 public function getTranslatedDayName($context = null, $keySuffix = '', $defaultValue = null); 2283 2284 /** 2285 * Get the translation of the current abbreviated week day name (with context for languages with multiple forms). 2286 * 2287 * @param string|null $context whole format string 2288 * 2289 * @return string 2290 */ 2291 public function getTranslatedMinDayName($context = null); 2292 2293 /** 2294 * Get the translation of the current month day name (with context for languages with multiple forms). 2295 * 2296 * @param string|null $context whole format string 2297 * @param string $keySuffix "" or "_short" 2298 * @param string|null $defaultValue default value if translation missing 2299 * 2300 * @return string 2301 */ 2302 public function getTranslatedMonthName($context = null, $keySuffix = '', $defaultValue = null); 2303 2304 /** 2305 * Get the translation of the current short week day name (with context for languages with multiple forms). 2306 * 2307 * @param string|null $context whole format string 2308 * 2309 * @return string 2310 */ 2311 public function getTranslatedShortDayName($context = null); 2312 2313 /** 2314 * Get the translation of the current short month day name (with context for languages with multiple forms). 2315 * 2316 * @param string|null $context whole format string 2317 * 2318 * @return string 2319 */ 2320 public function getTranslatedShortMonthName($context = null); 2321 2322 /** 2323 * Returns raw translation message for a given key. 2324 * 2325 * @param string $key key to find 2326 * @param string|null $locale current locale used if null 2327 * @param string|null $default default value if translation returns the key 2328 * @param \Symfony\Component\Translation\TranslatorInterface $translator an optional translator to use 2329 * 2330 * @return string 2331 */ 2332 public function getTranslationMessage(string $key, ?string $locale = null, ?string $default = null, $translator = null); 2333 2334 /** 2335 * Returns raw translation message for a given key. 2336 * 2337 * @param \Symfony\Component\Translation\TranslatorInterface $translator the translator to use 2338 * @param string $key key to find 2339 * @param string|null $locale current locale used if null 2340 * @param string|null $default default value if translation returns the key 2341 * 2342 * @return string 2343 */ 2344 public static function getTranslationMessageWith($translator, string $key, ?string $locale = null, ?string $default = null); 2345 2346 /** 2347 * Get the default translator instance in use. 2348 * 2349 * @return \Symfony\Component\Translation\TranslatorInterface 2350 */ 2351 public static function getTranslator(); 2352 2353 /** 2354 * Get the last day of week 2355 * 2356 * @return int 2357 */ 2358 public static function getWeekEndsAt(); 2359 2360 /** 2361 * Get the first day of week 2362 * 2363 * @return int 2364 */ 2365 public static function getWeekStartsAt(); 2366 2367 /** 2368 * Get weekend days 2369 * 2370 * @return array 2371 */ 2372 public static function getWeekendDays(); 2373 2374 /** 2375 * Determines if the instance is greater (after) than another 2376 * 2377 * @example 2378 * ``` 2379 * Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:15'); // true 2380 * Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:16'); // false 2381 * Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:17'); // false 2382 * ``` 2383 * 2384 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 2385 * 2386 * @return bool 2387 */ 2388 public function greaterThan($date): bool; 2389 2390 /** 2391 * Determines if the instance is greater (after) than or equal to another 2392 * 2393 * @example 2394 * ``` 2395 * Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:15'); // true 2396 * Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:16'); // true 2397 * Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:17'); // false 2398 * ``` 2399 * 2400 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 2401 * 2402 * @return bool 2403 */ 2404 public function greaterThanOrEqualTo($date): bool; 2405 2406 /** 2407 * Determines if the instance is greater (after) than another 2408 * 2409 * @example 2410 * ``` 2411 * Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:15'); // true 2412 * Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:16'); // false 2413 * Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:17'); // false 2414 * ``` 2415 * 2416 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 2417 * 2418 * @see greaterThan() 2419 * 2420 * @return bool 2421 */ 2422 public function gt($date): bool; 2423 2424 /** 2425 * Determines if the instance is greater (after) than or equal to another 2426 * 2427 * @example 2428 * ``` 2429 * Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:15'); // true 2430 * Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:16'); // true 2431 * Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:17'); // false 2432 * ``` 2433 * 2434 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 2435 * 2436 * @see greaterThanOrEqualTo() 2437 * 2438 * @return bool 2439 */ 2440 public function gte($date): bool; 2441 2442 /** 2443 * Checks if the (date)time string is in a given format. 2444 * 2445 * @example 2446 * ``` 2447 * Carbon::hasFormat('11:12:45', 'h:i:s'); // true 2448 * Carbon::hasFormat('13:12:45', 'h:i:s'); // false 2449 * ``` 2450 * 2451 * @param string $date 2452 * @param string $format 2453 * 2454 * @return bool 2455 */ 2456 public static function hasFormat($date, $format); 2457 2458 /** 2459 * Checks if the (date)time string is in a given format. 2460 * 2461 * @example 2462 * ``` 2463 * Carbon::hasFormatWithModifiers('31/08/2015', 'd#m#Y'); // true 2464 * Carbon::hasFormatWithModifiers('31/08/2015', 'm#d#Y'); // false 2465 * ``` 2466 * 2467 * @param string $date 2468 * @param string $format 2469 * 2470 * @return bool 2471 */ 2472 public static function hasFormatWithModifiers($date, $format): bool; 2473 2474 /** 2475 * Checks if macro is registered globally or locally. 2476 * 2477 * @param string $name 2478 * 2479 * @return bool 2480 */ 2481 public function hasLocalMacro($name); 2482 2483 /** 2484 * Return true if the current instance has its own translator. 2485 * 2486 * @return bool 2487 */ 2488 public function hasLocalTranslator(); 2489 2490 /** 2491 * Checks if macro is registered globally. 2492 * 2493 * @param string $name 2494 * 2495 * @return bool 2496 */ 2497 public static function hasMacro($name); 2498 2499 /** 2500 * Determine if a time string will produce a relative date. 2501 * 2502 * @param string $time 2503 * 2504 * @return bool true if time match a relative date, false if absolute or invalid time string 2505 */ 2506 public static function hasRelativeKeywords($time); 2507 2508 /** 2509 * Determine if there is a valid test instance set. A valid test instance 2510 * is anything that is not null. 2511 * 2512 * @return bool true if there is a test instance, otherwise false 2513 */ 2514 public static function hasTestNow(); 2515 2516 /** 2517 * Create a Carbon instance from a DateTime one. 2518 * 2519 * @param DateTimeInterface $date 2520 * 2521 * @return static 2522 */ 2523 public static function instance($date); 2524 2525 /** 2526 * Returns true if the current date matches the given string. 2527 * 2528 * @example 2529 * ``` 2530 * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019')); // true 2531 * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2018')); // false 2532 * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019-06')); // true 2533 * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('06-02')); // true 2534 * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019-06-02')); // true 2535 * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('Sunday')); // true 2536 * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('June')); // true 2537 * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23')); // true 2538 * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23:45')); // true 2539 * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23:00')); // false 2540 * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12h')); // true 2541 * var_dump(Carbon::parse('2019-06-02 15:23:45')->is('3pm')); // true 2542 * var_dump(Carbon::parse('2019-06-02 15:23:45')->is('3am')); // false 2543 * ``` 2544 * 2545 * @param string $tester day name, month name, hour, date, etc. as string 2546 * 2547 * @return bool 2548 */ 2549 public function is(string $tester); 2550 2551 /** 2552 * Determines if the instance is greater (after) than another 2553 * 2554 * @example 2555 * ``` 2556 * Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:15'); // true 2557 * Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:16'); // false 2558 * Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:17'); // false 2559 * ``` 2560 * 2561 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 2562 * 2563 * @see greaterThan() 2564 * 2565 * @return bool 2566 */ 2567 public function isAfter($date): bool; 2568 2569 /** 2570 * Determines if the instance is less (before) than another 2571 * 2572 * @example 2573 * ``` 2574 * Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:15'); // false 2575 * Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:16'); // false 2576 * Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:17'); // true 2577 * ``` 2578 * 2579 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 2580 * 2581 * @see lessThan() 2582 * 2583 * @return bool 2584 */ 2585 public function isBefore($date): bool; 2586 2587 /** 2588 * Determines if the instance is between two others 2589 * 2590 * @example 2591 * ``` 2592 * Carbon::parse('2018-07-25')->isBetween('2018-07-14', '2018-08-01'); // true 2593 * Carbon::parse('2018-07-25')->isBetween('2018-08-01', '2018-08-20'); // false 2594 * Carbon::parse('2018-07-25')->isBetween('2018-07-25', '2018-08-01'); // true 2595 * Carbon::parse('2018-07-25')->isBetween('2018-07-25', '2018-08-01', false); // false 2596 * ``` 2597 * 2598 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date1 2599 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date2 2600 * @param bool $equal Indicates if an equal to comparison should be done 2601 * 2602 * @return bool 2603 */ 2604 public function isBetween($date1, $date2, $equal = true): bool; 2605 2606 /** 2607 * Check if its the birthday. Compares the date/month values of the two dates. 2608 * 2609 * @example 2610 * ``` 2611 * Carbon::now()->subYears(5)->isBirthday(); // true 2612 * Carbon::now()->subYears(5)->subDay()->isBirthday(); // false 2613 * Carbon::parse('2019-06-05')->isBirthday(Carbon::parse('2001-06-05')); // true 2614 * Carbon::parse('2019-06-05')->isBirthday(Carbon::parse('2001-06-06')); // false 2615 * ``` 2616 * 2617 * @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use current day. 2618 * 2619 * @return bool 2620 */ 2621 public function isBirthday($date = null); 2622 2623 /** 2624 * Determines if the instance is in the current unit given. 2625 * 2626 * @example 2627 * ``` 2628 * Carbon::now()->isCurrentUnit('hour'); // true 2629 * Carbon::now()->subHours(2)->isCurrentUnit('hour'); // false 2630 * ``` 2631 * 2632 * @param string $unit The unit to test. 2633 * 2634 * @throws BadMethodCallException 2635 * 2636 * @return bool 2637 */ 2638 public function isCurrentUnit($unit); 2639 2640 /** 2641 * Checks if this day is a specific day of the week. 2642 * 2643 * @example 2644 * ``` 2645 * Carbon::parse('2019-07-17')->isDayOfWeek(Carbon::WEDNESDAY); // true 2646 * Carbon::parse('2019-07-17')->isDayOfWeek(Carbon::FRIDAY); // false 2647 * Carbon::parse('2019-07-17')->isDayOfWeek('Wednesday'); // true 2648 * Carbon::parse('2019-07-17')->isDayOfWeek('Friday'); // false 2649 * ``` 2650 * 2651 * @param int $dayOfWeek 2652 * 2653 * @return bool 2654 */ 2655 public function isDayOfWeek($dayOfWeek); 2656 2657 /** 2658 * Check if the instance is end of day. 2659 * 2660 * @example 2661 * ``` 2662 * Carbon::parse('2019-02-28 23:59:59.999999')->isEndOfDay(); // true 2663 * Carbon::parse('2019-02-28 23:59:59.123456')->isEndOfDay(); // true 2664 * Carbon::parse('2019-02-28 23:59:59')->isEndOfDay(); // true 2665 * Carbon::parse('2019-02-28 23:59:58.999999')->isEndOfDay(); // false 2666 * Carbon::parse('2019-02-28 23:59:59.999999')->isEndOfDay(true); // true 2667 * Carbon::parse('2019-02-28 23:59:59.123456')->isEndOfDay(true); // false 2668 * Carbon::parse('2019-02-28 23:59:59')->isEndOfDay(true); // false 2669 * ``` 2670 * 2671 * @param bool $checkMicroseconds check time at microseconds precision 2672 * 2673 * @return bool 2674 */ 2675 public function isEndOfDay($checkMicroseconds = false); 2676 2677 /** 2678 * Returns true if the date was created using CarbonImmutable::endOfTime() 2679 * 2680 * @return bool 2681 */ 2682 public function isEndOfTime(): bool; 2683 2684 /** 2685 * Determines if the instance is in the future, ie. greater (after) than now. 2686 * 2687 * @example 2688 * ``` 2689 * Carbon::now()->addHours(5)->isFuture(); // true 2690 * Carbon::now()->subHours(5)->isFuture(); // false 2691 * ``` 2692 * 2693 * @return bool 2694 */ 2695 public function isFuture(); 2696 2697 /** 2698 * Returns true if the current class/instance is immutable. 2699 * 2700 * @return bool 2701 */ 2702 public static function isImmutable(); 2703 2704 /** 2705 * Check if today is the last day of the Month 2706 * 2707 * @example 2708 * ``` 2709 * Carbon::parse('2019-02-28')->isLastOfMonth(); // true 2710 * Carbon::parse('2019-03-28')->isLastOfMonth(); // false 2711 * Carbon::parse('2019-03-30')->isLastOfMonth(); // false 2712 * Carbon::parse('2019-03-31')->isLastOfMonth(); // true 2713 * Carbon::parse('2019-04-30')->isLastOfMonth(); // true 2714 * ``` 2715 * 2716 * @return bool 2717 */ 2718 public function isLastOfMonth(); 2719 2720 /** 2721 * Determines if the instance is a leap year. 2722 * 2723 * @example 2724 * ``` 2725 * Carbon::parse('2020-01-01')->isLeapYear(); // true 2726 * Carbon::parse('2019-01-01')->isLeapYear(); // false 2727 * ``` 2728 * 2729 * @return bool 2730 */ 2731 public function isLeapYear(); 2732 2733 /** 2734 * Determines if the instance is a long year 2735 * 2736 * @example 2737 * ``` 2738 * Carbon::parse('2015-01-01')->isLongYear(); // true 2739 * Carbon::parse('2016-01-01')->isLongYear(); // false 2740 * ``` 2741 * 2742 * @see https://en.wikipedia.org/wiki/ISO_8601#Week_dates 2743 * 2744 * @return bool 2745 */ 2746 public function isLongYear(); 2747 2748 /** 2749 * Check if the instance is midday. 2750 * 2751 * @example 2752 * ``` 2753 * Carbon::parse('2019-02-28 11:59:59.999999')->isMidday(); // false 2754 * Carbon::parse('2019-02-28 12:00:00')->isMidday(); // true 2755 * Carbon::parse('2019-02-28 12:00:00.999999')->isMidday(); // true 2756 * Carbon::parse('2019-02-28 12:00:01')->isMidday(); // false 2757 * ``` 2758 * 2759 * @return bool 2760 */ 2761 public function isMidday(); 2762 2763 /** 2764 * Check if the instance is start of day / midnight. 2765 * 2766 * @example 2767 * ``` 2768 * Carbon::parse('2019-02-28 00:00:00')->isMidnight(); // true 2769 * Carbon::parse('2019-02-28 00:00:00.999999')->isMidnight(); // true 2770 * Carbon::parse('2019-02-28 00:00:01')->isMidnight(); // false 2771 * ``` 2772 * 2773 * @return bool 2774 */ 2775 public function isMidnight(); 2776 2777 /** 2778 * Returns true if a property can be changed via setter. 2779 * 2780 * @param string $unit 2781 * 2782 * @return bool 2783 */ 2784 public static function isModifiableUnit($unit); 2785 2786 /** 2787 * Returns true if the current class/instance is mutable. 2788 * 2789 * @return bool 2790 */ 2791 public static function isMutable(); 2792 2793 /** 2794 * Determines if the instance is in the past, ie. less (before) than now. 2795 * 2796 * @example 2797 * ``` 2798 * Carbon::now()->subHours(5)->isPast(); // true 2799 * Carbon::now()->addHours(5)->isPast(); // false 2800 * ``` 2801 * 2802 * @return bool 2803 */ 2804 public function isPast(); 2805 2806 /** 2807 * Compares the formatted values of the two dates. 2808 * 2809 * @example 2810 * ``` 2811 * Carbon::parse('2019-06-13')->isSameAs('Y-d', Carbon::parse('2019-12-13')); // true 2812 * Carbon::parse('2019-06-13')->isSameAs('Y-d', Carbon::parse('2019-06-14')); // false 2813 * ``` 2814 * 2815 * @param string $format date formats to compare. 2816 * @param \Carbon\Carbon|\DateTimeInterface|string|null $date instance to compare with or null to use current day. 2817 * 2818 * @return bool 2819 */ 2820 public function isSameAs($format, $date = null); 2821 2822 /** 2823 * Checks if the passed in date is in the same month as the instance´s month. 2824 * 2825 * @example 2826 * ``` 2827 * Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2019-01-01')); // true 2828 * Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2019-02-01')); // false 2829 * Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2018-01-01')); // false 2830 * Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2018-01-01'), false); // true 2831 * ``` 2832 * 2833 * @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use the current date. 2834 * @param bool $ofSameYear Check if it is the same month in the same year. 2835 * 2836 * @return bool 2837 */ 2838 public function isSameMonth($date = null, $ofSameYear = true); 2839 2840 /** 2841 * Checks if the passed in date is in the same quarter as the instance quarter (and year if needed). 2842 * 2843 * @example 2844 * ``` 2845 * Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2019-03-01')); // true 2846 * Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2019-04-01')); // false 2847 * Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2018-03-01')); // false 2848 * Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2018-03-01'), false); // true 2849 * ``` 2850 * 2851 * @param \Carbon\Carbon|\DateTimeInterface|string|null $date The instance to compare with or null to use current day. 2852 * @param bool $ofSameYear Check if it is the same month in the same year. 2853 * 2854 * @return bool 2855 */ 2856 public function isSameQuarter($date = null, $ofSameYear = true); 2857 2858 /** 2859 * Determines if the instance is in the current unit given. 2860 * 2861 * @example 2862 * ``` 2863 * Carbon::parse('2019-01-13')->isSameUnit('year', Carbon::parse('2019-12-25')); // true 2864 * Carbon::parse('2018-12-13')->isSameUnit('year', Carbon::parse('2019-12-25')); // false 2865 * ``` 2866 * 2867 * @param string $unit singular unit string 2868 * @param \Carbon\Carbon|\DateTimeInterface|null $date instance to compare with or null to use current day. 2869 * 2870 * @throws BadComparisonUnitException 2871 * 2872 * @return bool 2873 */ 2874 public function isSameUnit($unit, $date = null); 2875 2876 /** 2877 * Check if the instance is start of day / midnight. 2878 * 2879 * @example 2880 * ``` 2881 * Carbon::parse('2019-02-28 00:00:00')->isStartOfDay(); // true 2882 * Carbon::parse('2019-02-28 00:00:00.999999')->isStartOfDay(); // true 2883 * Carbon::parse('2019-02-28 00:00:01')->isStartOfDay(); // false 2884 * Carbon::parse('2019-02-28 00:00:00.000000')->isStartOfDay(true); // true 2885 * Carbon::parse('2019-02-28 00:00:00.000012')->isStartOfDay(true); // false 2886 * ``` 2887 * 2888 * @param bool $checkMicroseconds check time at microseconds precision 2889 * 2890 * @return bool 2891 */ 2892 public function isStartOfDay($checkMicroseconds = false); 2893 2894 /** 2895 * Returns true if the date was created using CarbonImmutable::startOfTime() 2896 * 2897 * @return bool 2898 */ 2899 public function isStartOfTime(): bool; 2900 2901 /** 2902 * Returns true if the strict mode is globally in use, false else. 2903 * (It can be overridden in specific instances.) 2904 * 2905 * @return bool 2906 */ 2907 public static function isStrictModeEnabled(); 2908 2909 /** 2910 * Determines if the instance is today. 2911 * 2912 * @example 2913 * ``` 2914 * Carbon::today()->isToday(); // true 2915 * Carbon::tomorrow()->isToday(); // false 2916 * ``` 2917 * 2918 * @return bool 2919 */ 2920 public function isToday(); 2921 2922 /** 2923 * Determines if the instance is tomorrow. 2924 * 2925 * @example 2926 * ``` 2927 * Carbon::tomorrow()->isTomorrow(); // true 2928 * Carbon::yesterday()->isTomorrow(); // false 2929 * ``` 2930 * 2931 * @return bool 2932 */ 2933 public function isTomorrow(); 2934 2935 /** 2936 * Determines if the instance is a weekday. 2937 * 2938 * @example 2939 * ``` 2940 * Carbon::parse('2019-07-14')->isWeekday(); // false 2941 * Carbon::parse('2019-07-15')->isWeekday(); // true 2942 * ``` 2943 * 2944 * @return bool 2945 */ 2946 public function isWeekday(); 2947 2948 /** 2949 * Determines if the instance is a weekend day. 2950 * 2951 * @example 2952 * ``` 2953 * Carbon::parse('2019-07-14')->isWeekend(); // true 2954 * Carbon::parse('2019-07-15')->isWeekend(); // false 2955 * ``` 2956 * 2957 * @return bool 2958 */ 2959 public function isWeekend(); 2960 2961 /** 2962 * Determines if the instance is yesterday. 2963 * 2964 * @example 2965 * ``` 2966 * Carbon::yesterday()->isYesterday(); // true 2967 * Carbon::tomorrow()->isYesterday(); // false 2968 * ``` 2969 * 2970 * @return bool 2971 */ 2972 public function isYesterday(); 2973 2974 /** 2975 * Format in the current language using ISO replacement patterns. 2976 * 2977 * @param string $format 2978 * @param string|null $originalFormat provide context if a chunk has been passed alone 2979 * 2980 * @return string 2981 */ 2982 public function isoFormat(string $format, ?string $originalFormat = null): string; 2983 2984 /** 2985 * Get/set the week number using given first day of week and first 2986 * day of year included in the first week. Or use ISO format if no settings 2987 * given. 2988 * 2989 * @param int|null $week 2990 * @param int|null $dayOfWeek 2991 * @param int|null $dayOfYear 2992 * 2993 * @return int|static 2994 */ 2995 public function isoWeek($week = null, $dayOfWeek = null, $dayOfYear = null); 2996 2997 /** 2998 * Set/get the week number of year using given first day of week and first 2999 * day of year included in the first week. Or use ISO format if no settings 3000 * given. 3001 * 3002 * @param int|null $year if null, act as a getter, if not null, set the year and return current instance. 3003 * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday) 3004 * @param int|null $dayOfYear first day of year included in the week #1 3005 * 3006 * @return int|static 3007 */ 3008 public function isoWeekYear($year = null, $dayOfWeek = null, $dayOfYear = null); 3009 3010 /** 3011 * Get/set the ISO weekday from 1 (Monday) to 7 (Sunday). 3012 * 3013 * @param int|null $value new value for weekday if using as setter. 3014 * 3015 * @return static|int 3016 */ 3017 public function isoWeekday($value = null); 3018 3019 /** 3020 * Get the number of weeks of the current week-year using given first day of week and first 3021 * day of year included in the first week. Or use ISO format if no settings 3022 * given. 3023 * 3024 * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday) 3025 * @param int|null $dayOfYear first day of year included in the week #1 3026 * 3027 * @return int 3028 */ 3029 public function isoWeeksInYear($dayOfWeek = null, $dayOfYear = null); 3030 3031 /** 3032 * Prepare the object for JSON serialization. 3033 * 3034 * @return array|string 3035 */ 3036 #[ReturnTypeWillChange] 3037 public function jsonSerialize(); 3038 3039 /** 3040 * Modify to the last occurrence of a given day of the week 3041 * in the current month. If no dayOfWeek is provided, modify to the 3042 * last day of the current month. Use the supplied constants 3043 * to indicate the desired dayOfWeek, ex. static::MONDAY. 3044 * 3045 * @param int|null $dayOfWeek 3046 * 3047 * @return static 3048 */ 3049 public function lastOfMonth($dayOfWeek = null); 3050 3051 /** 3052 * Modify to the last occurrence of a given day of the week 3053 * in the current quarter. If no dayOfWeek is provided, modify to the 3054 * last day of the current quarter. Use the supplied constants 3055 * to indicate the desired dayOfWeek, ex. static::MONDAY. 3056 * 3057 * @param int|null $dayOfWeek day of the week default null 3058 * 3059 * @return static 3060 */ 3061 public function lastOfQuarter($dayOfWeek = null); 3062 3063 /** 3064 * Modify to the last occurrence of a given day of the week 3065 * in the current year. If no dayOfWeek is provided, modify to the 3066 * last day of the current year. Use the supplied constants 3067 * to indicate the desired dayOfWeek, ex. static::MONDAY. 3068 * 3069 * @param int|null $dayOfWeek day of the week default null 3070 * 3071 * @return static 3072 */ 3073 public function lastOfYear($dayOfWeek = null); 3074 3075 /** 3076 * Determines if the instance is less (before) than another 3077 * 3078 * @example 3079 * ``` 3080 * Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:15'); // false 3081 * Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:16'); // false 3082 * Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:17'); // true 3083 * ``` 3084 * 3085 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 3086 * 3087 * @return bool 3088 */ 3089 public function lessThan($date): bool; 3090 3091 /** 3092 * Determines if the instance is less (before) or equal to another 3093 * 3094 * @example 3095 * ``` 3096 * Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:15'); // false 3097 * Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:16'); // true 3098 * Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:17'); // true 3099 * ``` 3100 * 3101 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 3102 * 3103 * @return bool 3104 */ 3105 public function lessThanOrEqualTo($date): bool; 3106 3107 /** 3108 * Get/set the locale for the current instance. 3109 * 3110 * @param string|null $locale 3111 * @param string ...$fallbackLocales 3112 * 3113 * @return $this|string 3114 */ 3115 public function locale(?string $locale = null, ...$fallbackLocales); 3116 3117 /** 3118 * Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow). 3119 * Support is considered enabled if the 3 words are translated in the given locale. 3120 * 3121 * @param string $locale locale ex. en 3122 * 3123 * @return bool 3124 */ 3125 public static function localeHasDiffOneDayWords($locale); 3126 3127 /** 3128 * Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after). 3129 * Support is considered enabled if the 4 sentences are translated in the given locale. 3130 * 3131 * @param string $locale locale ex. en 3132 * 3133 * @return bool 3134 */ 3135 public static function localeHasDiffSyntax($locale); 3136 3137 /** 3138 * Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow). 3139 * Support is considered enabled if the 2 words are translated in the given locale. 3140 * 3141 * @param string $locale locale ex. en 3142 * 3143 * @return bool 3144 */ 3145 public static function localeHasDiffTwoDayWords($locale); 3146 3147 /** 3148 * Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X). 3149 * Support is considered enabled if the 4 sentences are translated in the given locale. 3150 * 3151 * @param string $locale locale ex. en 3152 * 3153 * @return bool 3154 */ 3155 public static function localeHasPeriodSyntax($locale); 3156 3157 /** 3158 * Returns true if the given locale is internally supported and has short-units support. 3159 * Support is considered enabled if either year, day or hour has a short variant translated. 3160 * 3161 * @param string $locale locale ex. en 3162 * 3163 * @return bool 3164 */ 3165 public static function localeHasShortUnits($locale); 3166 3167 /** 3168 * Determines if the instance is less (before) than another 3169 * 3170 * @example 3171 * ``` 3172 * Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:15'); // false 3173 * Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:16'); // false 3174 * Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:17'); // true 3175 * ``` 3176 * 3177 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 3178 * 3179 * @see lessThan() 3180 * 3181 * @return bool 3182 */ 3183 public function lt($date): bool; 3184 3185 /** 3186 * Determines if the instance is less (before) or equal to another 3187 * 3188 * @example 3189 * ``` 3190 * Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:15'); // false 3191 * Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:16'); // true 3192 * Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:17'); // true 3193 * ``` 3194 * 3195 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 3196 * 3197 * @see lessThanOrEqualTo() 3198 * 3199 * @return bool 3200 */ 3201 public function lte($date): bool; 3202 3203 /** 3204 * Register a custom macro. 3205 * 3206 * @example 3207 * ``` 3208 * $userSettings = [ 3209 * 'locale' => 'pt', 3210 * 'timezone' => 'America/Sao_Paulo', 3211 * ]; 3212 * Carbon::macro('userFormat', function () use ($userSettings) { 3213 * return $this->copy()->locale($userSettings['locale'])->tz($userSettings['timezone'])->calendar(); 3214 * }); 3215 * echo Carbon::yesterday()->hours(11)->userFormat(); 3216 * ``` 3217 * 3218 * @param string $name 3219 * @param object|callable $macro 3220 * 3221 * @return void 3222 */ 3223 public static function macro($name, $macro); 3224 3225 /** 3226 * Make a Carbon instance from given variable if possible. 3227 * 3228 * Always return a new instance. Parse only strings and only these likely to be dates (skip intervals 3229 * and recurrences). Throw an exception for invalid format, but otherwise return null. 3230 * 3231 * @param mixed $var 3232 * 3233 * @throws InvalidFormatException 3234 * 3235 * @return static|null 3236 */ 3237 public static function make($var); 3238 3239 /** 3240 * Get the maximum instance between a given instance (default now) and the current instance. 3241 * 3242 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 3243 * 3244 * @return static 3245 */ 3246 public function max($date = null); 3247 3248 /** 3249 * Create a Carbon instance for the greatest supported date. 3250 * 3251 * @return static 3252 */ 3253 public static function maxValue(); 3254 3255 /** 3256 * Get the maximum instance between a given instance (default now) and the current instance. 3257 * 3258 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 3259 * 3260 * @see max() 3261 * 3262 * @return static 3263 */ 3264 public function maximum($date = null); 3265 3266 /** 3267 * Return the meridiem of the current time in the current locale. 3268 * 3269 * @param bool $isLower if true, returns lowercase variant if available in the current locale. 3270 * 3271 * @return string 3272 */ 3273 public function meridiem(bool $isLower = false): string; 3274 3275 /** 3276 * Modify to midday, default to self::$midDayAt 3277 * 3278 * @return static 3279 */ 3280 public function midDay(); 3281 3282 /** 3283 * Get the minimum instance between a given instance (default now) and the current instance. 3284 * 3285 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 3286 * 3287 * @return static 3288 */ 3289 public function min($date = null); 3290 3291 /** 3292 * Create a Carbon instance for the lowest supported date. 3293 * 3294 * @return static 3295 */ 3296 public static function minValue(); 3297 3298 /** 3299 * Get the minimum instance between a given instance (default now) and the current instance. 3300 * 3301 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 3302 * 3303 * @see min() 3304 * 3305 * @return static 3306 */ 3307 public function minimum($date = null); 3308 3309 /** 3310 * Mix another object into the class. 3311 * 3312 * @example 3313 * ``` 3314 * Carbon::mixin(new class { 3315 * public function addMoon() { 3316 * return function () { 3317 * return $this->addDays(30); 3318 * }; 3319 * } 3320 * public function subMoon() { 3321 * return function () { 3322 * return $this->subDays(30); 3323 * }; 3324 * } 3325 * }); 3326 * $fullMoon = Carbon::create('2018-12-22'); 3327 * $nextFullMoon = $fullMoon->addMoon(); 3328 * $blackMoon = Carbon::create('2019-01-06'); 3329 * $previousBlackMoon = $blackMoon->subMoon(); 3330 * echo "$nextFullMoon\n"; 3331 * echo "$previousBlackMoon\n"; 3332 * ``` 3333 * 3334 * @param object|string $mixin 3335 * 3336 * @throws ReflectionException 3337 * 3338 * @return void 3339 */ 3340 public static function mixin($mixin); 3341 3342 /** 3343 * Calls \DateTime::modify if mutable or \DateTimeImmutable::modify else. 3344 * 3345 * @see https://php.net/manual/en/datetime.modify.php 3346 * 3347 * @return static|false 3348 */ 3349 #[ReturnTypeWillChange] 3350 public function modify($modify); 3351 3352 /** 3353 * Determines if the instance is not equal to another 3354 * 3355 * @example 3356 * ``` 3357 * Carbon::parse('2018-07-25 12:45:16')->ne('2018-07-25 12:45:16'); // false 3358 * Carbon::parse('2018-07-25 12:45:16')->ne(Carbon::parse('2018-07-25 12:45:16')); // false 3359 * Carbon::parse('2018-07-25 12:45:16')->ne('2018-07-25 12:45:17'); // true 3360 * ``` 3361 * 3362 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 3363 * 3364 * @see notEqualTo() 3365 * 3366 * @return bool 3367 */ 3368 public function ne($date): bool; 3369 3370 /** 3371 * Modify to the next occurrence of a given modifier such as a day of 3372 * the week. If no modifier is provided, modify to the next occurrence 3373 * of the current day of the week. Use the supplied constants 3374 * to indicate the desired dayOfWeek, ex. static::MONDAY. 3375 * 3376 * @param string|int|null $modifier 3377 * 3378 * @return static 3379 */ 3380 public function next($modifier = null); 3381 3382 /** 3383 * Go forward to the next weekday. 3384 * 3385 * @return static 3386 */ 3387 public function nextWeekday(); 3388 3389 /** 3390 * Go forward to the next weekend day. 3391 * 3392 * @return static 3393 */ 3394 public function nextWeekendDay(); 3395 3396 /** 3397 * Determines if the instance is not equal to another 3398 * 3399 * @example 3400 * ``` 3401 * Carbon::parse('2018-07-25 12:45:16')->notEqualTo('2018-07-25 12:45:16'); // false 3402 * Carbon::parse('2018-07-25 12:45:16')->notEqualTo(Carbon::parse('2018-07-25 12:45:16')); // false 3403 * Carbon::parse('2018-07-25 12:45:16')->notEqualTo('2018-07-25 12:45:17'); // true 3404 * ``` 3405 * 3406 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date 3407 * 3408 * @return bool 3409 */ 3410 public function notEqualTo($date): bool; 3411 3412 /** 3413 * Get a Carbon instance for the current date and time. 3414 * 3415 * @param DateTimeZone|string|null $tz 3416 * 3417 * @return static 3418 */ 3419 public static function now($tz = null); 3420 3421 /** 3422 * Returns a present instance in the same timezone. 3423 * 3424 * @return static 3425 */ 3426 public function nowWithSameTz(); 3427 3428 /** 3429 * Modify to the given occurrence of a given day of the week 3430 * in the current month. If the calculated occurrence is outside the scope 3431 * of the current month, then return false and no modifications are made. 3432 * Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY. 3433 * 3434 * @param int $nth 3435 * @param int $dayOfWeek 3436 * 3437 * @return mixed 3438 */ 3439 public function nthOfMonth($nth, $dayOfWeek); 3440 3441 /** 3442 * Modify to the given occurrence of a given day of the week 3443 * in the current quarter. If the calculated occurrence is outside the scope 3444 * of the current quarter, then return false and no modifications are made. 3445 * Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY. 3446 * 3447 * @param int $nth 3448 * @param int $dayOfWeek 3449 * 3450 * @return mixed 3451 */ 3452 public function nthOfQuarter($nth, $dayOfWeek); 3453 3454 /** 3455 * Modify to the given occurrence of a given day of the week 3456 * in the current year. If the calculated occurrence is outside the scope 3457 * of the current year, then return false and no modifications are made. 3458 * Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY. 3459 * 3460 * @param int $nth 3461 * @param int $dayOfWeek 3462 * 3463 * @return mixed 3464 */ 3465 public function nthOfYear($nth, $dayOfWeek); 3466 3467 /** 3468 * Return a property with its ordinal. 3469 * 3470 * @param string $key 3471 * @param string|null $period 3472 * 3473 * @return string 3474 */ 3475 public function ordinal(string $key, ?string $period = null): string; 3476 3477 /** 3478 * Create a carbon instance from a string. 3479 * 3480 * This is an alias for the constructor that allows better fluent syntax 3481 * as it allows you to do Carbon::parse('Monday next week')->fn() rather 3482 * than (new Carbon('Monday next week'))->fn(). 3483 * 3484 * @param string|DateTimeInterface|null $time 3485 * @param DateTimeZone|string|null $tz 3486 * 3487 * @throws InvalidFormatException 3488 * 3489 * @return static 3490 */ 3491 public static function parse($time = null, $tz = null); 3492 3493 /** 3494 * Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.). 3495 * 3496 * @param string $time date/time string in the given language (may also contain English). 3497 * @param string|null $locale if locale is null or not specified, current global locale will be 3498 * used instead. 3499 * @param DateTimeZone|string|null $tz optional timezone for the new instance. 3500 * 3501 * @throws InvalidFormatException 3502 * 3503 * @return static 3504 */ 3505 public static function parseFromLocale($time, $locale = null, $tz = null); 3506 3507 /** 3508 * Returns standardized plural of a given singular/plural unit name (in English). 3509 * 3510 * @param string $unit 3511 * 3512 * @return string 3513 */ 3514 public static function pluralUnit(string $unit): string; 3515 3516 /** 3517 * Modify to the previous occurrence of a given modifier such as a day of 3518 * the week. If no dayOfWeek is provided, modify to the previous occurrence 3519 * of the current day of the week. Use the supplied constants 3520 * to indicate the desired dayOfWeek, ex. static::MONDAY. 3521 * 3522 * @param string|int|null $modifier 3523 * 3524 * @return static 3525 */ 3526 public function previous($modifier = null); 3527 3528 /** 3529 * Go backward to the previous weekday. 3530 * 3531 * @return static 3532 */ 3533 public function previousWeekday(); 3534 3535 /** 3536 * Go backward to the previous weekend day. 3537 * 3538 * @return static 3539 */ 3540 public function previousWeekendDay(); 3541 3542 /** 3543 * Create a iterable CarbonPeriod object from current date to a given end date (and optional interval). 3544 * 3545 * @param \DateTimeInterface|Carbon|CarbonImmutable|null $end period end date 3546 * @param int|\DateInterval|string|null $interval period default interval or number of the given $unit 3547 * @param string|null $unit if specified, $interval must be an integer 3548 * 3549 * @return CarbonPeriod 3550 */ 3551 public function range($end = null, $interval = null, $unit = null); 3552 3553 /** 3554 * Call native PHP DateTime/DateTimeImmutable add() method. 3555 * 3556 * @param DateInterval $interval 3557 * 3558 * @return static 3559 */ 3560 public function rawAdd(DateInterval $interval); 3561 3562 /** 3563 * Create a Carbon instance from a specific format. 3564 * 3565 * @param string $format Datetime format 3566 * @param string $time 3567 * @param DateTimeZone|string|false|null $tz 3568 * 3569 * @throws InvalidFormatException 3570 * 3571 * @return static|false 3572 */ 3573 public static function rawCreateFromFormat($format, $time, $tz = null); 3574 3575 /** 3576 * @see https://php.net/manual/en/datetime.format.php 3577 * 3578 * @param string $format 3579 * 3580 * @return string 3581 */ 3582 public function rawFormat($format); 3583 3584 /** 3585 * Create a carbon instance from a string. 3586 * 3587 * This is an alias for the constructor that allows better fluent syntax 3588 * as it allows you to do Carbon::parse('Monday next week')->fn() rather 3589 * than (new Carbon('Monday next week'))->fn(). 3590 * 3591 * @param string|DateTimeInterface|null $time 3592 * @param DateTimeZone|string|null $tz 3593 * 3594 * @throws InvalidFormatException 3595 * 3596 * @return static 3597 */ 3598 public static function rawParse($time = null, $tz = null); 3599 3600 /** 3601 * Call native PHP DateTime/DateTimeImmutable sub() method. 3602 * 3603 * @param DateInterval $interval 3604 * 3605 * @return static 3606 */ 3607 public function rawSub(DateInterval $interval); 3608 3609 /** 3610 * Remove all macros and generic macros. 3611 */ 3612 public static function resetMacros(); 3613 3614 /** 3615 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 3616 * You should rather use the ->settings() method. 3617 * Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants 3618 * are available for quarters, years, decade, centuries, millennia (singular and plural forms). 3619 * @see settings 3620 * 3621 * Reset the month overflow behavior. 3622 * 3623 * @return void 3624 */ 3625 public static function resetMonthsOverflow(); 3626 3627 /** 3628 * Reset the format used to the default when type juggling a Carbon instance to a string 3629 * 3630 * @return void 3631 */ 3632 public static function resetToStringFormat(); 3633 3634 /** 3635 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 3636 * You should rather use the ->settings() method. 3637 * Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants 3638 * are available for quarters, years, decade, centuries, millennia (singular and plural forms). 3639 * @see settings 3640 * 3641 * Reset the month overflow behavior. 3642 * 3643 * @return void 3644 */ 3645 public static function resetYearsOverflow(); 3646 3647 /** 3648 * Round the current instance second with given precision if specified. 3649 * 3650 * @param float|int|string|\DateInterval|null $precision 3651 * @param string $function 3652 * 3653 * @return CarbonInterface 3654 */ 3655 public function round($precision = 1, $function = 'round'); 3656 3657 /** 3658 * Round the current instance at the given unit with given precision if specified and the given function. 3659 * 3660 * @param string $unit 3661 * @param float|int $precision 3662 * @param string $function 3663 * 3664 * @return CarbonInterface 3665 */ 3666 public function roundUnit($unit, $precision = 1, $function = 'round'); 3667 3668 /** 3669 * Round the current instance week. 3670 * 3671 * @param int $weekStartsAt optional start allow you to specify the day of week to use to start the week 3672 * 3673 * @return CarbonInterface 3674 */ 3675 public function roundWeek($weekStartsAt = null); 3676 3677 /** 3678 * The number of seconds since midnight. 3679 * 3680 * @return int 3681 */ 3682 public function secondsSinceMidnight(); 3683 3684 /** 3685 * The number of seconds until 23:59:59. 3686 * 3687 * @return int 3688 */ 3689 public function secondsUntilEndOfDay(); 3690 3691 /** 3692 * Return a serialized string of the instance. 3693 * 3694 * @return string 3695 */ 3696 public function serialize(); 3697 3698 /** 3699 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 3700 * You should rather transform Carbon object before the serialization. 3701 * 3702 * JSON serialize all Carbon instances using the given callback. 3703 * 3704 * @param callable $callback 3705 * 3706 * @return void 3707 */ 3708 public static function serializeUsing($callback); 3709 3710 /** 3711 * Set a part of the Carbon object 3712 * 3713 * @param string|array $name 3714 * @param string|int|DateTimeZone $value 3715 * 3716 * @throws ImmutableException|UnknownSetterException 3717 * 3718 * @return $this 3719 */ 3720 public function set($name, $value = null); 3721 3722 /** 3723 * Set the date with gregorian year, month and day numbers. 3724 * 3725 * @see https://php.net/manual/en/datetime.setdate.php 3726 * 3727 * @param int $year 3728 * @param int $month 3729 * @param int $day 3730 * 3731 * @return static 3732 */ 3733 #[ReturnTypeWillChange] 3734 public function setDate($year, $month, $day); 3735 3736 /** 3737 * Set the year, month, and date for this instance to that of the passed instance. 3738 * 3739 * @param Carbon|DateTimeInterface $date now if null 3740 * 3741 * @return static 3742 */ 3743 public function setDateFrom($date = null); 3744 3745 /** 3746 * Set the date and time all together. 3747 * 3748 * @param int $year 3749 * @param int $month 3750 * @param int $day 3751 * @param int $hour 3752 * @param int $minute 3753 * @param int $second 3754 * @param int $microseconds 3755 * 3756 * @return static 3757 */ 3758 public function setDateTime($year, $month, $day, $hour, $minute, $second = 0, $microseconds = 0); 3759 3760 /** 3761 * Set the date and time for this instance to that of the passed instance. 3762 * 3763 * @param Carbon|DateTimeInterface $date 3764 * 3765 * @return static 3766 */ 3767 public function setDateTimeFrom($date = null); 3768 3769 /** 3770 * Set the fallback locale. 3771 * 3772 * @see https://symfony.com/doc/current/components/translation.html#fallback-locales 3773 * 3774 * @param string $locale 3775 */ 3776 public static function setFallbackLocale($locale); 3777 3778 /** 3779 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 3780 * You should rather use the ->settings() method. 3781 * @see settings 3782 * 3783 * @param int $humanDiffOptions 3784 */ 3785 public static function setHumanDiffOptions($humanDiffOptions); 3786 3787 /** 3788 * Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates. 3789 * 3790 * @see https://php.net/manual/en/datetime.setisodate.php 3791 * 3792 * @param int $year 3793 * @param int $week 3794 * @param int $day 3795 * 3796 * @return static 3797 */ 3798 #[ReturnTypeWillChange] 3799 public function setISODate($year, $week, $day = 1); 3800 3801 /** 3802 * Set the translator for the current instance. 3803 * 3804 * @param \Symfony\Component\Translation\TranslatorInterface $translator 3805 * 3806 * @return $this 3807 */ 3808 public function setLocalTranslator(TranslatorInterface $translator); 3809 3810 /** 3811 * Set the current translator locale and indicate if the source locale file exists. 3812 * Pass 'auto' as locale to use closest language from the current LC_TIME locale. 3813 * 3814 * @param string $locale locale ex. en 3815 * 3816 * @return bool 3817 */ 3818 public static function setLocale($locale); 3819 3820 /** 3821 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 3822 * You should rather consider mid-day is always 12pm, then if you need to test if it's an other 3823 * hour, test it explicitly: 3824 * $date->format('G') == 13 3825 * or to set explicitly to a given hour: 3826 * $date->setTime(13, 0, 0, 0) 3827 * 3828 * Set midday/noon hour 3829 * 3830 * @param int $hour midday hour 3831 * 3832 * @return void 3833 */ 3834 public static function setMidDayAt($hour); 3835 3836 /** 3837 * Set a Carbon instance (real or mock) to be returned when a "now" 3838 * instance is created. The provided instance will be returned 3839 * specifically under the following conditions: 3840 * - A call to the static now() method, ex. Carbon::now() 3841 * - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null) 3842 * - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now') 3843 * - When a string containing the desired time is passed to Carbon::parse(). 3844 * 3845 * Note the timezone parameter was left out of the examples above and 3846 * has no affect as the mock value will be returned regardless of its value. 3847 * 3848 * To clear the test instance call this method using the default 3849 * parameter of null. 3850 * 3851 * /!\ Use this method for unit tests only. 3852 * 3853 * @param Closure|static|string|false|null $testNow real or mock Carbon instance 3854 */ 3855 public static function setTestNow($testNow = null); 3856 3857 /** 3858 * Resets the current time of the DateTime object to a different time. 3859 * 3860 * @see https://php.net/manual/en/datetime.settime.php 3861 * 3862 * @param int $hour 3863 * @param int $minute 3864 * @param int $second 3865 * @param int $microseconds 3866 * 3867 * @return static 3868 */ 3869 #[ReturnTypeWillChange] 3870 public function setTime($hour, $minute, $second = 0, $microseconds = 0); 3871 3872 /** 3873 * Set the hour, minute, second and microseconds for this instance to that of the passed instance. 3874 * 3875 * @param Carbon|DateTimeInterface $date now if null 3876 * 3877 * @return static 3878 */ 3879 public function setTimeFrom($date = null); 3880 3881 /** 3882 * Set the time by time string. 3883 * 3884 * @param string $time 3885 * 3886 * @return static 3887 */ 3888 public function setTimeFromTimeString($time); 3889 3890 /** 3891 * Set the instance's timestamp. 3892 * 3893 * Timestamp input can be given as int, float or a string containing one or more numbers. 3894 * 3895 * @param float|int|string $unixTimestamp 3896 * 3897 * @return static 3898 */ 3899 #[ReturnTypeWillChange] 3900 public function setTimestamp($unixTimestamp); 3901 3902 /** 3903 * Set the instance's timezone from a string or object. 3904 * 3905 * @param DateTimeZone|string $value 3906 * 3907 * @return static 3908 */ 3909 #[ReturnTypeWillChange] 3910 public function setTimezone($value); 3911 3912 /** 3913 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 3914 * You should rather let Carbon object being casted to string with DEFAULT_TO_STRING_FORMAT, and 3915 * use other method or custom format passed to format() method if you need to dump an other string 3916 * format. 3917 * 3918 * Set the default format used when type juggling a Carbon instance to a string 3919 * 3920 * @param string|Closure|null $format 3921 * 3922 * @return void 3923 */ 3924 public static function setToStringFormat($format); 3925 3926 /** 3927 * Set the default translator instance to use. 3928 * 3929 * @param \Symfony\Component\Translation\TranslatorInterface $translator 3930 * 3931 * @return void 3932 */ 3933 public static function setTranslator(TranslatorInterface $translator); 3934 3935 /** 3936 * Set specified unit to new given value. 3937 * 3938 * @param string $unit year, month, day, hour, minute, second or microsecond 3939 * @param int $value new value for given unit 3940 * 3941 * @return static 3942 */ 3943 public function setUnit($unit, $value = null); 3944 3945 /** 3946 * Set any unit to a new value without overflowing current other unit given. 3947 * 3948 * @param string $valueUnit unit name to modify 3949 * @param int $value new value for the input unit 3950 * @param string $overflowUnit unit name to not overflow 3951 * 3952 * @return static 3953 */ 3954 public function setUnitNoOverflow($valueUnit, $value, $overflowUnit); 3955 3956 /** 3957 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 3958 * You should rather use UTF-8 language packages on every machine. 3959 * 3960 * Set if UTF8 will be used for localized date/time. 3961 * 3962 * @param bool $utf8 3963 */ 3964 public static function setUtf8($utf8); 3965 3966 /** 3967 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 3968 * Use $weekStartsAt optional parameter instead when using startOfWeek, floorWeek, ceilWeek 3969 * or roundWeek method. You can also use the 'first_day_of_week' locale setting to change the 3970 * start of week according to current locale selected and implicitly the end of week. 3971 * 3972 * Set the last day of week 3973 * 3974 * @param int|string $day week end day (or 'auto' to get the day before the first day of week 3975 * from Carbon::getLocale() culture). 3976 * 3977 * @return void 3978 */ 3979 public static function setWeekEndsAt($day); 3980 3981 /** 3982 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 3983 * Use $weekEndsAt optional parameter instead when using endOfWeek method. You can also use the 3984 * 'first_day_of_week' locale setting to change the start of week according to current locale 3985 * selected and implicitly the end of week. 3986 * 3987 * Set the first day of week 3988 * 3989 * @param int|string $day week start day (or 'auto' to get the first day of week from Carbon::getLocale() culture). 3990 * 3991 * @return void 3992 */ 3993 public static function setWeekStartsAt($day); 3994 3995 /** 3996 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 3997 * You should rather consider week-end is always saturday and sunday, and if you have some custom 3998 * week-end days to handle, give to those days an other name and create a macro for them: 3999 * 4000 * ``` 4001 * Carbon::macro('isDayOff', function ($date) { 4002 * return $date->isSunday() || $date->isMonday(); 4003 * }); 4004 * Carbon::macro('isNotDayOff', function ($date) { 4005 * return !$date->isDayOff(); 4006 * }); 4007 * if ($someDate->isDayOff()) ... 4008 * if ($someDate->isNotDayOff()) ... 4009 * // Add 5 not-off days 4010 * $count = 5; 4011 * while ($someDate->isDayOff() || ($count-- > 0)) { 4012 * $someDate->addDay(); 4013 * } 4014 * ``` 4015 * 4016 * Set weekend days 4017 * 4018 * @param array $days 4019 * 4020 * @return void 4021 */ 4022 public static function setWeekendDays($days); 4023 4024 /** 4025 * Set specific options. 4026 * - strictMode: true|false|null 4027 * - monthOverflow: true|false|null 4028 * - yearOverflow: true|false|null 4029 * - humanDiffOptions: int|null 4030 * - toStringFormat: string|Closure|null 4031 * - toJsonFormat: string|Closure|null 4032 * - locale: string|null 4033 * - timezone: \DateTimeZone|string|int|null 4034 * - macros: array|null 4035 * - genericMacros: array|null 4036 * 4037 * @param array $settings 4038 * 4039 * @return $this|static 4040 */ 4041 public function settings(array $settings); 4042 4043 /** 4044 * Set the instance's timezone from a string or object and add/subtract the offset difference. 4045 * 4046 * @param DateTimeZone|string $value 4047 * 4048 * @return static 4049 */ 4050 public function shiftTimezone($value); 4051 4052 /** 4053 * Get the month overflow global behavior (can be overridden in specific instances). 4054 * 4055 * @return bool 4056 */ 4057 public static function shouldOverflowMonths(); 4058 4059 /** 4060 * Get the month overflow global behavior (can be overridden in specific instances). 4061 * 4062 * @return bool 4063 */ 4064 public static function shouldOverflowYears(); 4065 4066 /** 4067 * @alias diffForHumans 4068 * 4069 * Get the difference in a human readable format in the current locale from current instance to an other 4070 * instance given (or now if null given). 4071 */ 4072 public function since($other = null, $syntax = null, $short = false, $parts = 1, $options = null); 4073 4074 /** 4075 * Returns standardized singular of a given singular/plural unit name (in English). 4076 * 4077 * @param string $unit 4078 * 4079 * @return string 4080 */ 4081 public static function singularUnit(string $unit): string; 4082 4083 /** 4084 * Modify to start of current given unit. 4085 * 4086 * @example 4087 * ``` 4088 * echo Carbon::parse('2018-07-25 12:45:16.334455') 4089 * ->startOf('month') 4090 * ->endOf('week', Carbon::FRIDAY); 4091 * ``` 4092 * 4093 * @param string $unit 4094 * @param array<int, mixed> $params 4095 * 4096 * @return static 4097 */ 4098 public function startOf($unit, ...$params); 4099 4100 /** 4101 * Resets the date to the first day of the century and the time to 00:00:00 4102 * 4103 * @example 4104 * ``` 4105 * echo Carbon::parse('2018-07-25 12:45:16')->startOfCentury(); 4106 * ``` 4107 * 4108 * @return static 4109 */ 4110 public function startOfCentury(); 4111 4112 /** 4113 * Resets the time to 00:00:00 start of day 4114 * 4115 * @example 4116 * ``` 4117 * echo Carbon::parse('2018-07-25 12:45:16')->startOfDay(); 4118 * ``` 4119 * 4120 * @return static 4121 */ 4122 public function startOfDay(); 4123 4124 /** 4125 * Resets the date to the first day of the decade and the time to 00:00:00 4126 * 4127 * @example 4128 * ``` 4129 * echo Carbon::parse('2018-07-25 12:45:16')->startOfDecade(); 4130 * ``` 4131 * 4132 * @return static 4133 */ 4134 public function startOfDecade(); 4135 4136 /** 4137 * Modify to start of current hour, minutes and seconds become 0 4138 * 4139 * @example 4140 * ``` 4141 * echo Carbon::parse('2018-07-25 12:45:16')->startOfHour(); 4142 * ``` 4143 * 4144 * @return static 4145 */ 4146 public function startOfHour(); 4147 4148 /** 4149 * Resets the date to the first day of the millennium and the time to 00:00:00 4150 * 4151 * @example 4152 * ``` 4153 * echo Carbon::parse('2018-07-25 12:45:16')->startOfMillennium(); 4154 * ``` 4155 * 4156 * @return static 4157 */ 4158 public function startOfMillennium(); 4159 4160 /** 4161 * Modify to start of current minute, seconds become 0 4162 * 4163 * @example 4164 * ``` 4165 * echo Carbon::parse('2018-07-25 12:45:16')->startOfMinute(); 4166 * ``` 4167 * 4168 * @return static 4169 */ 4170 public function startOfMinute(); 4171 4172 /** 4173 * Resets the date to the first day of the month and the time to 00:00:00 4174 * 4175 * @example 4176 * ``` 4177 * echo Carbon::parse('2018-07-25 12:45:16')->startOfMonth(); 4178 * ``` 4179 * 4180 * @return static 4181 */ 4182 public function startOfMonth(); 4183 4184 /** 4185 * Resets the date to the first day of the quarter and the time to 00:00:00 4186 * 4187 * @example 4188 * ``` 4189 * echo Carbon::parse('2018-07-25 12:45:16')->startOfQuarter(); 4190 * ``` 4191 * 4192 * @return static 4193 */ 4194 public function startOfQuarter(); 4195 4196 /** 4197 * Modify to start of current second, microseconds become 0 4198 * 4199 * @example 4200 * ``` 4201 * echo Carbon::parse('2018-07-25 12:45:16.334455') 4202 * ->startOfSecond() 4203 * ->format('H:i:s.u'); 4204 * ``` 4205 * 4206 * @return static 4207 */ 4208 public function startOfSecond(); 4209 4210 /** 4211 * Resets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00 4212 * 4213 * @example 4214 * ``` 4215 * echo Carbon::parse('2018-07-25 12:45:16')->startOfWeek() . "\n"; 4216 * echo Carbon::parse('2018-07-25 12:45:16')->locale('ar')->startOfWeek() . "\n"; 4217 * echo Carbon::parse('2018-07-25 12:45:16')->startOfWeek(Carbon::SUNDAY) . "\n"; 4218 * ``` 4219 * 4220 * @param int $weekStartsAt optional start allow you to specify the day of week to use to start the week 4221 * 4222 * @return static 4223 */ 4224 public function startOfWeek($weekStartsAt = null); 4225 4226 /** 4227 * Resets the date to the first day of the year and the time to 00:00:00 4228 * 4229 * @example 4230 * ``` 4231 * echo Carbon::parse('2018-07-25 12:45:16')->startOfYear(); 4232 * ``` 4233 * 4234 * @return static 4235 */ 4236 public function startOfYear(); 4237 4238 /** 4239 * Subtract given units or interval to the current instance. 4240 * 4241 * @example $date->sub('hour', 3) 4242 * @example $date->sub(15, 'days') 4243 * @example $date->sub(CarbonInterval::days(4)) 4244 * 4245 * @param string|DateInterval|Closure|CarbonConverterInterface $unit 4246 * @param int $value 4247 * @param bool|null $overflow 4248 * 4249 * @return static 4250 */ 4251 #[ReturnTypeWillChange] 4252 public function sub($unit, $value = 1, $overflow = null); 4253 4254 public function subRealUnit($unit, $value = 1); 4255 4256 /** 4257 * Subtract given units to the current instance. 4258 * 4259 * @param string $unit 4260 * @param int $value 4261 * @param bool|null $overflow 4262 * 4263 * @return static 4264 */ 4265 public function subUnit($unit, $value = 1, $overflow = null); 4266 4267 /** 4268 * Subtract any unit to a new value without overflowing current other unit given. 4269 * 4270 * @param string $valueUnit unit name to modify 4271 * @param int $value amount to subtract to the input unit 4272 * @param string $overflowUnit unit name to not overflow 4273 * 4274 * @return static 4275 */ 4276 public function subUnitNoOverflow($valueUnit, $value, $overflowUnit); 4277 4278 /** 4279 * Subtract given units or interval to the current instance. 4280 * 4281 * @see sub() 4282 * 4283 * @param string|DateInterval $unit 4284 * @param int $value 4285 * @param bool|null $overflow 4286 * 4287 * @return static 4288 */ 4289 public function subtract($unit, $value = 1, $overflow = null); 4290 4291 /** 4292 * Get the difference in a human readable format in the current locale from current instance to an other 4293 * instance given (or now if null given). 4294 * 4295 * @return string 4296 */ 4297 public function timespan($other = null, $timezone = null); 4298 4299 /** 4300 * Set the instance's timestamp. 4301 * 4302 * Timestamp input can be given as int, float or a string containing one or more numbers. 4303 * 4304 * @param float|int|string $unixTimestamp 4305 * 4306 * @return static 4307 */ 4308 public function timestamp($unixTimestamp); 4309 4310 /** 4311 * @alias setTimezone 4312 * 4313 * @param DateTimeZone|string $value 4314 * 4315 * @return static 4316 */ 4317 public function timezone($value); 4318 4319 /** 4320 * Get the difference in a human readable format in the current locale from an other 4321 * instance given (or now if null given) to current instance. 4322 * 4323 * When comparing a value in the past to default now: 4324 * 1 hour from now 4325 * 5 months from now 4326 * 4327 * When comparing a value in the future to default now: 4328 * 1 hour ago 4329 * 5 months ago 4330 * 4331 * When comparing a value in the past to another value: 4332 * 1 hour after 4333 * 5 months after 4334 * 4335 * When comparing a value in the future to another value: 4336 * 1 hour before 4337 * 5 months before 4338 * 4339 * @param Carbon|\DateTimeInterface|string|array|null $other if array passed, will be used as parameters array, see $syntax below; 4340 * if null passed, now will be used as comparison reference; 4341 * if any other type, it will be converted to date and used as reference. 4342 * @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains: 4343 * - 'syntax' entry (see below) 4344 * - 'short' entry (see below) 4345 * - 'parts' entry (see below) 4346 * - 'options' entry (see below) 4347 * - 'join' entry determines how to join multiple parts of the string 4348 * ` - if $join is a string, it's used as a joiner glue 4349 * ` - if $join is a callable/closure, it get the list of string and should return a string 4350 * ` - if $join is an array, the first item will be the default glue, and the second item 4351 * ` will be used instead of the glue for the last item 4352 * ` - if $join is true, it will be guessed from the locale ('list' translation file entry) 4353 * ` - if $join is missing, a space will be used as glue 4354 * - 'other' entry (see above) 4355 * if int passed, it add modifiers: 4356 * Possible values: 4357 * - CarbonInterface::DIFF_ABSOLUTE no modifiers 4358 * - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier 4359 * - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier 4360 * Default value: CarbonInterface::DIFF_ABSOLUTE 4361 * @param bool $short displays short format of time units 4362 * @param int $parts maximum number of parts to display (default value: 1: single unit) 4363 * @param int $options human diff options 4364 * 4365 * @return string 4366 */ 4367 public function to($other = null, $syntax = null, $short = false, $parts = 1, $options = null); 4368 4369 /** 4370 * Get default array representation. 4371 * 4372 * @example 4373 * ``` 4374 * var_dump(Carbon::now()->toArray()); 4375 * ``` 4376 * 4377 * @return array 4378 */ 4379 public function toArray(); 4380 4381 /** 4382 * Format the instance as ATOM 4383 * 4384 * @example 4385 * ``` 4386 * echo Carbon::now()->toAtomString(); 4387 * ``` 4388 * 4389 * @return string 4390 */ 4391 public function toAtomString(); 4392 4393 /** 4394 * Format the instance as COOKIE 4395 * 4396 * @example 4397 * ``` 4398 * echo Carbon::now()->toCookieString(); 4399 * ``` 4400 * 4401 * @return string 4402 */ 4403 public function toCookieString(); 4404 4405 /** 4406 * @alias toDateTime 4407 * 4408 * Return native DateTime PHP object matching the current instance. 4409 * 4410 * @example 4411 * ``` 4412 * var_dump(Carbon::now()->toDate()); 4413 * ``` 4414 * 4415 * @return DateTime 4416 */ 4417 public function toDate(); 4418 4419 /** 4420 * Format the instance as date 4421 * 4422 * @example 4423 * ``` 4424 * echo Carbon::now()->toDateString(); 4425 * ``` 4426 * 4427 * @return string 4428 */ 4429 public function toDateString(); 4430 4431 /** 4432 * Return native DateTime PHP object matching the current instance. 4433 * 4434 * @example 4435 * ``` 4436 * var_dump(Carbon::now()->toDateTime()); 4437 * ``` 4438 * 4439 * @return DateTime 4440 */ 4441 public function toDateTime(); 4442 4443 /** 4444 * Return native toDateTimeImmutable PHP object matching the current instance. 4445 * 4446 * @example 4447 * ``` 4448 * var_dump(Carbon::now()->toDateTimeImmutable()); 4449 * ``` 4450 * 4451 * @return DateTimeImmutable 4452 */ 4453 public function toDateTimeImmutable(); 4454 4455 /** 4456 * Format the instance as date and time T-separated with no timezone 4457 * 4458 * @example 4459 * ``` 4460 * echo Carbon::now()->toDateTimeLocalString(); 4461 * echo "\n"; 4462 * echo Carbon::now()->toDateTimeLocalString('minute'); // You can specify precision among: minute, second, millisecond and microsecond 4463 * ``` 4464 * 4465 * @param string $unitPrecision 4466 * 4467 * @return string 4468 */ 4469 public function toDateTimeLocalString($unitPrecision = 'second'); 4470 4471 /** 4472 * Format the instance as date and time 4473 * 4474 * @example 4475 * ``` 4476 * echo Carbon::now()->toDateTimeString(); 4477 * ``` 4478 * 4479 * @param string $unitPrecision 4480 * 4481 * @return string 4482 */ 4483 public function toDateTimeString($unitPrecision = 'second'); 4484 4485 /** 4486 * Format the instance with day, date and time 4487 * 4488 * @example 4489 * ``` 4490 * echo Carbon::now()->toDayDateTimeString(); 4491 * ``` 4492 * 4493 * @return string 4494 */ 4495 public function toDayDateTimeString(); 4496 4497 /** 4498 * Format the instance as a readable date 4499 * 4500 * @example 4501 * ``` 4502 * echo Carbon::now()->toFormattedDateString(); 4503 * ``` 4504 * 4505 * @return string 4506 */ 4507 public function toFormattedDateString(); 4508 4509 /** 4510 * Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z, if $keepOffset truthy, offset will be kept: 4511 * 1977-04-22T01:00:00-05:00). 4512 * 4513 * @example 4514 * ``` 4515 * echo Carbon::now('America/Toronto')->toISOString() . "\n"; 4516 * echo Carbon::now('America/Toronto')->toISOString(true) . "\n"; 4517 * ``` 4518 * 4519 * @param bool $keepOffset Pass true to keep the date offset. Else forced to UTC. 4520 * 4521 * @return null|string 4522 */ 4523 public function toISOString($keepOffset = false); 4524 4525 /** 4526 * Return a immutable copy of the instance. 4527 * 4528 * @return CarbonImmutable 4529 */ 4530 public function toImmutable(); 4531 4532 /** 4533 * Format the instance as ISO8601 4534 * 4535 * @example 4536 * ``` 4537 * echo Carbon::now()->toIso8601String(); 4538 * ``` 4539 * 4540 * @return string 4541 */ 4542 public function toIso8601String(); 4543 4544 /** 4545 * Convert the instance to UTC and return as Zulu ISO8601 4546 * 4547 * @example 4548 * ``` 4549 * echo Carbon::now()->toIso8601ZuluString(); 4550 * ``` 4551 * 4552 * @param string $unitPrecision 4553 * 4554 * @return string 4555 */ 4556 public function toIso8601ZuluString($unitPrecision = 'second'); 4557 4558 /** 4559 * Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z) with UTC timezone. 4560 * 4561 * @example 4562 * ``` 4563 * echo Carbon::now('America/Toronto')->toJSON(); 4564 * ``` 4565 * 4566 * @return null|string 4567 */ 4568 public function toJSON(); 4569 4570 /** 4571 * Return a mutable copy of the instance. 4572 * 4573 * @return Carbon 4574 */ 4575 public function toMutable(); 4576 4577 /** 4578 * Get the difference in a human readable format in the current locale from an other 4579 * instance given to now 4580 * 4581 * @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains: 4582 * - 'syntax' entry (see below) 4583 * - 'short' entry (see below) 4584 * - 'parts' entry (see below) 4585 * - 'options' entry (see below) 4586 * - 'join' entry determines how to join multiple parts of the string 4587 * ` - if $join is a string, it's used as a joiner glue 4588 * ` - if $join is a callable/closure, it get the list of string and should return a string 4589 * ` - if $join is an array, the first item will be the default glue, and the second item 4590 * ` will be used instead of the glue for the last item 4591 * ` - if $join is true, it will be guessed from the locale ('list' translation file entry) 4592 * ` - if $join is missing, a space will be used as glue 4593 * if int passed, it add modifiers: 4594 * Possible values: 4595 * - CarbonInterface::DIFF_ABSOLUTE no modifiers 4596 * - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier 4597 * - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier 4598 * Default value: CarbonInterface::DIFF_ABSOLUTE 4599 * @param bool $short displays short format of time units 4600 * @param int $parts maximum number of parts to display (default value: 1: single part) 4601 * @param int $options human diff options 4602 * 4603 * @return string 4604 */ 4605 public function toNow($syntax = null, $short = false, $parts = 1, $options = null); 4606 4607 /** 4608 * Get default object representation. 4609 * 4610 * @example 4611 * ``` 4612 * var_dump(Carbon::now()->toObject()); 4613 * ``` 4614 * 4615 * @return object 4616 */ 4617 public function toObject(); 4618 4619 /** 4620 * Create a iterable CarbonPeriod object from current date to a given end date (and optional interval). 4621 * 4622 * @param \DateTimeInterface|Carbon|CarbonImmutable|int|null $end period end date or recurrences count if int 4623 * @param int|\DateInterval|string|null $interval period default interval or number of the given $unit 4624 * @param string|null $unit if specified, $interval must be an integer 4625 * 4626 * @return CarbonPeriod 4627 */ 4628 public function toPeriod($end = null, $interval = null, $unit = null); 4629 4630 /** 4631 * Format the instance as RFC1036 4632 * 4633 * @example 4634 * ``` 4635 * echo Carbon::now()->toRfc1036String(); 4636 * ``` 4637 * 4638 * @return string 4639 */ 4640 public function toRfc1036String(); 4641 4642 /** 4643 * Format the instance as RFC1123 4644 * 4645 * @example 4646 * ``` 4647 * echo Carbon::now()->toRfc1123String(); 4648 * ``` 4649 * 4650 * @return string 4651 */ 4652 public function toRfc1123String(); 4653 4654 /** 4655 * Format the instance as RFC2822 4656 * 4657 * @example 4658 * ``` 4659 * echo Carbon::now()->toRfc2822String(); 4660 * ``` 4661 * 4662 * @return string 4663 */ 4664 public function toRfc2822String(); 4665 4666 /** 4667 * Format the instance as RFC3339 4668 * 4669 * @param bool $extended 4670 * 4671 * @example 4672 * ``` 4673 * echo Carbon::now()->toRfc3339String() . "\n"; 4674 * echo Carbon::now()->toRfc3339String(true) . "\n"; 4675 * ``` 4676 * 4677 * @return string 4678 */ 4679 public function toRfc3339String($extended = false); 4680 4681 /** 4682 * Format the instance as RFC7231 4683 * 4684 * @example 4685 * ``` 4686 * echo Carbon::now()->toRfc7231String(); 4687 * ``` 4688 * 4689 * @return string 4690 */ 4691 public function toRfc7231String(); 4692 4693 /** 4694 * Format the instance as RFC822 4695 * 4696 * @example 4697 * ``` 4698 * echo Carbon::now()->toRfc822String(); 4699 * ``` 4700 * 4701 * @return string 4702 */ 4703 public function toRfc822String(); 4704 4705 /** 4706 * Format the instance as RFC850 4707 * 4708 * @example 4709 * ``` 4710 * echo Carbon::now()->toRfc850String(); 4711 * ``` 4712 * 4713 * @return string 4714 */ 4715 public function toRfc850String(); 4716 4717 /** 4718 * Format the instance as RSS 4719 * 4720 * @example 4721 * ``` 4722 * echo Carbon::now()->toRssString(); 4723 * ``` 4724 * 4725 * @return string 4726 */ 4727 public function toRssString(); 4728 4729 /** 4730 * Returns english human readable complete date string. 4731 * 4732 * @example 4733 * ``` 4734 * echo Carbon::now()->toString(); 4735 * ``` 4736 * 4737 * @return string 4738 */ 4739 public function toString(); 4740 4741 /** 4742 * Format the instance as time 4743 * 4744 * @example 4745 * ``` 4746 * echo Carbon::now()->toTimeString(); 4747 * ``` 4748 * 4749 * @param string $unitPrecision 4750 * 4751 * @return string 4752 */ 4753 public function toTimeString($unitPrecision = 'second'); 4754 4755 /** 4756 * Format the instance as W3C 4757 * 4758 * @example 4759 * ``` 4760 * echo Carbon::now()->toW3cString(); 4761 * ``` 4762 * 4763 * @return string 4764 */ 4765 public function toW3cString(); 4766 4767 /** 4768 * Create a Carbon instance for today. 4769 * 4770 * @param DateTimeZone|string|null $tz 4771 * 4772 * @return static 4773 */ 4774 public static function today($tz = null); 4775 4776 /** 4777 * Create a Carbon instance for tomorrow. 4778 * 4779 * @param DateTimeZone|string|null $tz 4780 * 4781 * @return static 4782 */ 4783 public static function tomorrow($tz = null); 4784 4785 /** 4786 * Translate using translation string or callback available. 4787 * 4788 * @param string $key 4789 * @param array $parameters 4790 * @param string|int|float|null $number 4791 * @param \Symfony\Component\Translation\TranslatorInterface|null $translator 4792 * @param bool $altNumbers 4793 * 4794 * @return string 4795 */ 4796 public function translate(string $key, array $parameters = [], $number = null, ?TranslatorInterface $translator = null, bool $altNumbers = false): string; 4797 4798 /** 4799 * Returns the alternative number for a given integer if available in the current locale. 4800 * 4801 * @param int $number 4802 * 4803 * @return string 4804 */ 4805 public function translateNumber(int $number): string; 4806 4807 /** 4808 * Translate a time string from a locale to an other. 4809 * 4810 * @param string $timeString date/time/duration string to translate (may also contain English) 4811 * @param string|null $from input locale of the $timeString parameter (`Carbon::getLocale()` by default) 4812 * @param string|null $to output locale of the result returned (`"en"` by default) 4813 * @param int $mode specify what to translate with options: 4814 * - self::TRANSLATE_ALL (default) 4815 * - CarbonInterface::TRANSLATE_MONTHS 4816 * - CarbonInterface::TRANSLATE_DAYS 4817 * - CarbonInterface::TRANSLATE_UNITS 4818 * - CarbonInterface::TRANSLATE_MERIDIEM 4819 * You can use pipe to group: CarbonInterface::TRANSLATE_MONTHS | CarbonInterface::TRANSLATE_DAYS 4820 * 4821 * @return string 4822 */ 4823 public static function translateTimeString($timeString, $from = null, $to = null, $mode = self::TRANSLATE_ALL); 4824 4825 /** 4826 * Translate a time string from the current locale (`$date->locale()`) to an other. 4827 * 4828 * @param string $timeString time string to translate 4829 * @param string|null $to output locale of the result returned ("en" by default) 4830 * 4831 * @return string 4832 */ 4833 public function translateTimeStringTo($timeString, $to = null); 4834 4835 /** 4836 * Translate using translation string or callback available. 4837 * 4838 * @param \Symfony\Component\Translation\TranslatorInterface $translator 4839 * @param string $key 4840 * @param array $parameters 4841 * @param null $number 4842 * 4843 * @return string 4844 */ 4845 public static function translateWith(TranslatorInterface $translator, string $key, array $parameters = [], $number = null): string; 4846 4847 /** 4848 * Format as ->format() do (using date replacements patterns from https://php.net/manual/en/function.date.php) 4849 * but translate words whenever possible (months, day names, etc.) using the current locale. 4850 * 4851 * @param string $format 4852 * 4853 * @return string 4854 */ 4855 public function translatedFormat(string $format): string; 4856 4857 /** 4858 * Set the timezone or returns the timezone name if no arguments passed. 4859 * 4860 * @param DateTimeZone|string $value 4861 * 4862 * @return static|string 4863 */ 4864 public function tz($value = null); 4865 4866 /** 4867 * @alias getTimestamp 4868 * 4869 * Returns the UNIX timestamp for the current date. 4870 * 4871 * @return int 4872 */ 4873 public function unix(); 4874 4875 /** 4876 * @alias to 4877 * 4878 * Get the difference in a human readable format in the current locale from an other 4879 * instance given (or now if null given) to current instance. 4880 * 4881 * @param Carbon|\DateTimeInterface|string|array|null $other if array passed, will be used as parameters array, see $syntax below; 4882 * if null passed, now will be used as comparison reference; 4883 * if any other type, it will be converted to date and used as reference. 4884 * @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains: 4885 * - 'syntax' entry (see below) 4886 * - 'short' entry (see below) 4887 * - 'parts' entry (see below) 4888 * - 'options' entry (see below) 4889 * - 'join' entry determines how to join multiple parts of the string 4890 * ` - if $join is a string, it's used as a joiner glue 4891 * ` - if $join is a callable/closure, it get the list of string and should return a string 4892 * ` - if $join is an array, the first item will be the default glue, and the second item 4893 * ` will be used instead of the glue for the last item 4894 * ` - if $join is true, it will be guessed from the locale ('list' translation file entry) 4895 * ` - if $join is missing, a space will be used as glue 4896 * - 'other' entry (see above) 4897 * if int passed, it add modifiers: 4898 * Possible values: 4899 * - CarbonInterface::DIFF_ABSOLUTE no modifiers 4900 * - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier 4901 * - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier 4902 * Default value: CarbonInterface::DIFF_ABSOLUTE 4903 * @param bool $short displays short format of time units 4904 * @param int $parts maximum number of parts to display (default value: 1: single unit) 4905 * @param int $options human diff options 4906 * 4907 * @return string 4908 */ 4909 public function until($other = null, $syntax = null, $short = false, $parts = 1, $options = null); 4910 4911 /** 4912 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 4913 * You should rather use the ->settings() method. 4914 * Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants 4915 * are available for quarters, years, decade, centuries, millennia (singular and plural forms). 4916 * @see settings 4917 * 4918 * Indicates if months should be calculated with overflow. 4919 * 4920 * @param bool $monthsOverflow 4921 * 4922 * @return void 4923 */ 4924 public static function useMonthsOverflow($monthsOverflow = true); 4925 4926 /** 4927 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 4928 * You should rather use the ->settings() method. 4929 * @see settings 4930 * 4931 * Enable the strict mode (or disable with passing false). 4932 * 4933 * @param bool $strictModeEnabled 4934 */ 4935 public static function useStrictMode($strictModeEnabled = true); 4936 4937 /** 4938 * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. 4939 * You should rather use the ->settings() method. 4940 * Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants 4941 * are available for quarters, years, decade, centuries, millennia (singular and plural forms). 4942 * @see settings 4943 * 4944 * Indicates if years should be calculated with overflow. 4945 * 4946 * @param bool $yearsOverflow 4947 * 4948 * @return void 4949 */ 4950 public static function useYearsOverflow($yearsOverflow = true); 4951 4952 /** 4953 * Set the instance's timezone to UTC. 4954 * 4955 * @return static 4956 */ 4957 public function utc(); 4958 4959 /** 4960 * Returns the minutes offset to UTC if no arguments passed, else set the timezone with given minutes shift passed. 4961 * 4962 * @param int|null $minuteOffset 4963 * 4964 * @return int|static 4965 */ 4966 public function utcOffset(?int $minuteOffset = null); 4967 4968 /** 4969 * Returns the milliseconds timestamps used amongst other by Date javascript objects. 4970 * 4971 * @return float 4972 */ 4973 public function valueOf(); 4974 4975 /** 4976 * Get/set the week number using given first day of week and first 4977 * day of year included in the first week. Or use US format if no settings 4978 * given (Sunday / Jan 6). 4979 * 4980 * @param int|null $week 4981 * @param int|null $dayOfWeek 4982 * @param int|null $dayOfYear 4983 * 4984 * @return int|static 4985 */ 4986 public function week($week = null, $dayOfWeek = null, $dayOfYear = null); 4987 4988 /** 4989 * Set/get the week number of year using given first day of week and first 4990 * day of year included in the first week. Or use US format if no settings 4991 * given (Sunday / Jan 6). 4992 * 4993 * @param int|null $year if null, act as a getter, if not null, set the year and return current instance. 4994 * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday) 4995 * @param int|null $dayOfYear first day of year included in the week #1 4996 * 4997 * @return int|static 4998 */ 4999 public function weekYear($year = null, $dayOfWeek = null, $dayOfYear = null); 5000 5001 /** 5002 * Get/set the weekday from 0 (Sunday) to 6 (Saturday). 5003 * 5004 * @param int|null $value new value for weekday if using as setter. 5005 * 5006 * @return static|int 5007 */ 5008 public function weekday($value = null); 5009 5010 /** 5011 * Get the number of weeks of the current week-year using given first day of week and first 5012 * day of year included in the first week. Or use US format if no settings 5013 * given (Sunday / Jan 6). 5014 * 5015 * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday) 5016 * @param int|null $dayOfYear first day of year included in the week #1 5017 * 5018 * @return int 5019 */ 5020 public function weeksInYear($dayOfWeek = null, $dayOfYear = null); 5021 5022 /** 5023 * Temporarily sets a static date to be used within the callback. 5024 * Using setTestNow to set the date, executing the callback, then 5025 * clearing the test instance. 5026 * 5027 * /!\ Use this method for unit tests only. 5028 * 5029 * @param Closure|static|string|false|null $testNow real or mock Carbon instance 5030 * @param Closure|null $callback 5031 * 5032 * @return mixed 5033 */ 5034 public static function withTestNow($testNow = null, $callback = null); 5035 5036 /** 5037 * Create a Carbon instance for yesterday. 5038 * 5039 * @param DateTimeZone|string|null $tz 5040 * 5041 * @return static 5042 */ 5043 public static function yesterday($tz = null); 5044 5045 // </methods> 5046} 5047