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