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