Vous êtes connecté en tant que anonymous Se Deconnecter
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon; use Closure; use DateInterval; use DateTime; use DateTimeInterface; use InvalidArgumentException; use JsonSerializable; use ReflectionException; /** * Common interface for Carbon and CarbonImmutable. * * * * @property int $year * @property int $yearIso * @property int $month * @property int $day * @property int $hour * @property int $minute * @property int $second * @property int $micro * @property int $microsecond * @property int $timestamp seconds since the Unix Epoch * @property string $englishDayOfWeek the day of week in English * @property string $shortEnglishDayOfWeek the abbreviated day of week in English * @property string $englishMonth the month in English * @property string $shortEnglishMonth the abbreviated month in English * @property string $localeDayOfWeek the day of week in current locale LC_TIME * @property string $shortLocaleDayOfWeek the abbreviated day of week in current locale LC_TIME * @property string $localeMonth the month in current locale LC_TIME * @property string $shortLocaleMonth the abbreviated month in current locale LC_TIME * @property int $milliseconds * @property int $millisecond * @property int $milli * @property int $week 1 through 53 * @property int $isoWeek 1 through 53 * @property int $weekYear year according to week format * @property int $isoWeekYear year according to ISO week format * @property int $dayOfYear 1 through 366 * @property int $age does a diffInYears() with default parameters * @property int $offset the timezone offset in seconds from UTC * @property int $offsetMinutes the timezone offset in minutes from UTC * @property int $offsetHours the timezone offset in hours from UTC * @property CarbonTimeZone $timezone the current timezone * @property CarbonTimeZone $tz alias of $timezone * @property-read int $dayOfWeek 0 (for Sunday) through 6 (for Saturday) * @property-read int $dayOfWeekIso 1 (for Monday) through 7 (for Sunday) * @property-read int $weekOfYear ISO-8601 week number of year, weeks starting on Monday * @property-read int $daysInMonth number of days in the given month * @property-read string $latinMeridiem "am"/"pm" (Ante meridiem or Post meridiem latin lowercase mark) * @property-read string $latinUpperMeridiem "AM"/"PM" (Ante meridiem or Post meridiem latin uppercase mark) * @property-read string $dayName long name of weekday translated according to Carbon locale, in english if no translation available for current language * @property-read string $shortDayName short name of weekday translated according to Carbon locale, in english if no translation available for current language * @property-read string $minDayName very short name of weekday translated according to Carbon locale, in english if no translation available for current language * @property-read string $monthName long name of month translated according to Carbon locale, in english if no translation available for current language * @property-read string $shortMonthName short name of month translated according to Carbon locale, in english if no translation available for current language * @property-read string $meridiem lowercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language * @property-read string $upperMeridiem uppercase meridiem mark translated according to Carbon locale, in latin if no translation available for current language * @property-read int $noZeroHour current hour from 1 to 24 * @property-read int $weeksInYear 51 through 53 * @property-read int $isoWeeksInYear 51 through 53 * @property-read int $weekOfMonth 1 through 5 * @property-read int $weekNumberInMonth 1 through 5 * @property-read int $firstWeekDay 0 through 6 * @property-read int $lastWeekDay 0 through 6 * @property-read int $daysInYear 365 or 366 * @property-read int $quarter the quarter of this instance, 1 - 4 * @property-read int $decade the decade of this instance * @property-read int $century the century of this instance * @property-read int $millennium the millennium of this instance * @property-read bool $dst daylight savings time indicator, true if DST, false otherwise * @property-read bool $local checks if the timezone is local, true if local, false otherwise * @property-read bool $utc checks if the timezone is UTC, true if UTC, false otherwise * @property-read string $timezoneName the current timezone name * @property-read string $tzName alias of $timezoneName * @property-read string $timezoneAbbreviatedName the current timezone abbreviated name * @property-read string $tzAbbrName alias of $timezoneAbbreviatedName * @property-read string $locale locale of the current instance * * @method bool isUtc() Check if the current instance has UTC timezone. (Both isUtc and isUTC cases are valid.) * @method bool isLocal() Check if the current instance has non-UTC timezone. * @method bool isValid() Check if the current instance is a valid date. * @method bool isDST() Check if the current instance is in a daylight saving time. * @method bool isSunday() Checks if the instance day is sunday. * @method bool isMonday() Checks if the instance day is monday. * @method bool isTuesday() Checks if the instance day is tuesday. * @method bool isWednesday() Checks if the instance day is wednesday. * @method bool isThursday() Checks if the instance day is thursday. * @method bool isFriday() Checks if the instance day is friday. * @method bool isSaturday() Checks if the instance day is saturday. * @method bool isSameYear(\DateTimeInterface $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). * @method bool isCurrentYear() Checks if the instance is in the same year as the current moment. * @method bool isNextYear() Checks if the instance is in the same year as the current moment next year. * @method bool isLastYear() Checks if the instance is in the same year as the current moment last year. * @method bool isSameWeek(\DateTimeInterface $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). * @method bool isCurrentWeek() Checks if the instance is in the same week as the current moment. * @method bool isNextWeek() Checks if the instance is in the same week as the current moment next week. * @method bool isLastWeek() Checks if the instance is in the same week as the current moment last week. * @method bool isSameDay(\DateTimeInterface $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). * @method bool isCurrentDay() Checks if the instance is in the same day as the current moment. * @method bool isNextDay() Checks if the instance is in the same day as the current moment next day. * @method bool isLastDay() Checks if the instance is in the same day as the current moment last day. * @method bool isSameHour(\DateTimeInterface $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). * @method bool isCurrentHour() Checks if the instance is in the same hour as the current moment. * @method bool isNextHour() Checks if the instance is in the same hour as the current moment next hour. * @method bool isLastHour() Checks if the instance is in the same hour as the current moment last hour. * @method bool isSameMinute(\DateTimeInterface $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). * @method bool isCurrentMinute() Checks if the instance is in the same minute as the current moment. * @method bool isNextMinute() Checks if the instance is in the same minute as the current moment next minute. * @method bool isLastMinute() Checks if the instance is in the same minute as the current moment last minute. * @method bool isSameSecond(\DateTimeInterface $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). * @method bool isCurrentSecond() Checks if the instance is in the same second as the current moment. * @method bool isNextSecond() Checks if the instance is in the same second as the current moment next second. * @method bool isLastSecond() Checks if the instance is in the same second as the current moment last second. * @method bool isSameMicro(\DateTimeInterface $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). * @method bool isCurrentMicro() Checks if the instance is in the same microsecond as the current moment. * @method bool isNextMicro() Checks if the instance is in the same microsecond as the current moment next microsecond. * @method bool isLastMicro() Checks if the instance is in the same microsecond as the current moment last microsecond. * @method bool isSameMicrosecond(\DateTimeInterface $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). * @method bool isCurrentMicrosecond() Checks if the instance is in the same microsecond as the current moment. * @method bool isNextMicrosecond() Checks if the instance is in the same microsecond as the current moment next microsecond. * @method bool isLastMicrosecond() Checks if the instance is in the same microsecond as the current moment last microsecond. * @method bool isCurrentMonth() Checks if the instance is in the same month as the current moment. * @method bool isNextMonth() Checks if the instance is in the same month as the current moment next month. * @method bool isLastMonth() Checks if the instance is in the same month as the current moment last month. * @method bool isCurrentQuarter() Checks if the instance is in the same quarter as the current moment. * @method bool isNextQuarter() Checks if the instance is in the same quarter as the current moment next quarter. * @method bool isLastQuarter() Checks if the instance is in the same quarter as the current moment last quarter. * @method bool isSameDecade(\DateTimeInterface $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). * @method bool isCurrentDecade() Checks if the instance is in the same decade as the current moment. * @method bool isNextDecade() Checks if the instance is in the same decade as the current moment next decade. * @method bool isLastDecade() Checks if the instance is in the same decade as the current moment last decade. * @method bool isSameCentury(\DateTimeInterface $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). * @method bool isCurrentCentury() Checks if the instance is in the same century as the current moment. * @method bool isNextCentury() Checks if the instance is in the same century as the current moment next century. * @method bool isLastCentury() Checks if the instance is in the same century as the current moment last century. * @method bool isSameMillennium(\DateTimeInterface $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). * @method bool isCurrentMillennium() Checks if the instance is in the same millennium as the current moment. * @method bool isNextMillennium() Checks if the instance is in the same millennium as the current moment next millennium. * @method bool isLastMillennium() Checks if the instance is in the same millennium as the current moment last millennium. * @method $this years(int $value) Set current instance year to the given value. * @method $this year(int $value) Set current instance year to the given value. * @method $this setYears(int $value) Set current instance year to the given value. * @method $this setYear(int $value) Set current instance year to the given value. * @method $this months(int $value) Set current instance month to the given value. * @method $this month(int $value) Set current instance month to the given value. * @method $this setMonths(int $value) Set current instance month to the given value. * @method $this setMonth(int $value) Set current instance month to the given value. * @method $this days(int $value) Set current instance day to the given value. * @method $this day(int $value) Set current instance day to the given value. * @method $this setDays(int $value) Set current instance day to the given value. * @method $this setDay(int $value) Set current instance day to the given value. * @method $this hours(int $value) Set current instance hour to the given value. * @method $this hour(int $value) Set current instance hour to the given value. * @method $this setHours(int $value) Set current instance hour to the given value. * @method $this setHour(int $value) Set current instance hour to the given value. * @method $this minutes(int $value) Set current instance minute to the given value. * @method $this minute(int $value) Set current instance minute to the given value. * @method $this setMinutes(int $value) Set current instance minute to the given value. * @method $this setMinute(int $value) Set current instance minute to the given value. * @method $this seconds(int $value) Set current instance second to the given value. * @method $this second(int $value) Set current instance second to the given value. * @method $this setSeconds(int $value) Set current instance second to the given value. * @method $this setSecond(int $value) Set current instance second to the given value. * @method $this millis(int $value) Set current instance millisecond to the given value. * @method $this milli(int $value) Set current instance millisecond to the given value. * @method $this setMillis(int $value) Set current instance millisecond to the given value. * @method $this setMilli(int $value) Set current instance millisecond to the given value. * @method $this milliseconds(int $value) Set current instance millisecond to the given value. * @method $this millisecond(int $value) Set current instance millisecond to the given value. * @method $this setMilliseconds(int $value) Set current instance millisecond to the given value. * @method $this setMillisecond(int $value) Set current instance millisecond to the given value. * @method $this micros(int $value) Set current instance microsecond to the given value. * @method $this micro(int $value) Set current instance microsecond to the given value. * @method $this setMicros(int $value) Set current instance microsecond to the given value. * @method $this setMicro(int $value) Set current instance microsecond to the given value. * @method $this microseconds(int $value) Set current instance microsecond to the given value. * @method $this microsecond(int $value) Set current instance microsecond to the given value. * @method $this setMicroseconds(int $value) Set current instance microsecond to the given value. * @method $this setMicrosecond(int $value) Set current instance microsecond to the given value. * @method $this addYears(int $value = 1) Add years (the $value count passed in) to the instance (using date interval). * @method $this addYear() Add one year to the instance (using date interval). * @method $this subYears(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval). * @method $this subYear() Sub one year to the instance (using date interval). * @method $this addYearsWithOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this addYearWithOverflow() Add one year to the instance (using date interval) with overflow explicitly allowed. * @method $this subYearsWithOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this subYearWithOverflow() Sub one year to the instance (using date interval) with overflow explicitly allowed. * @method $this addYearsWithoutOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addYearWithoutOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. * @method $this subYearsWithoutOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subYearWithoutOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. * @method $this addYearsWithNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addYearWithNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. * @method $this subYearsWithNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subYearWithNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. * @method $this addYearsNoOverflow(int $value = 1) Add years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addYearNoOverflow() Add one year to the instance (using date interval) with overflow explicitly forbidden. * @method $this subYearsNoOverflow(int $value = 1) Sub years (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subYearNoOverflow() Sub one year to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMonths(int $value = 1) Add months (the $value count passed in) to the instance (using date interval). * @method $this addMonth() Add one month to the instance (using date interval). * @method $this subMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval). * @method $this subMonth() Sub one month to the instance (using date interval). * @method $this addMonthsWithOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this addMonthWithOverflow() Add one month to the instance (using date interval) with overflow explicitly allowed. * @method $this subMonthsWithOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this subMonthWithOverflow() Sub one month to the instance (using date interval) with overflow explicitly allowed. * @method $this addMonthsWithoutOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMonthWithoutOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMonthsWithoutOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMonthWithoutOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMonthsWithNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMonthWithNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMonthsWithNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMonthWithNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMonthsNoOverflow(int $value = 1) Add months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMonthNoOverflow() Add one month to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMonthsNoOverflow(int $value = 1) Sub months (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMonthNoOverflow() Sub one month to the instance (using date interval) with overflow explicitly forbidden. * @method $this addDays(int $value = 1) Add days (the $value count passed in) to the instance (using date interval). * @method $this addDay() Add one day to the instance (using date interval). * @method $this subDays(int $value = 1) Sub days (the $value count passed in) to the instance (using date interval). * @method $this subDay() Sub one day to the instance (using date interval). * @method $this addHours(int $value = 1) Add hours (the $value count passed in) to the instance (using date interval). * @method $this addHour() Add one hour to the instance (using date interval). * @method $this subHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using date interval). * @method $this subHour() Sub one hour to the instance (using date interval). * @method $this addMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using date interval). * @method $this addMinute() Add one minute to the instance (using date interval). * @method $this subMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using date interval). * @method $this subMinute() Sub one minute to the instance (using date interval). * @method $this addSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using date interval). * @method $this addSecond() Add one second to the instance (using date interval). * @method $this subSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using date interval). * @method $this subSecond() Sub one second to the instance (using date interval). * @method $this addMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). * @method $this addMilli() Add one millisecond to the instance (using date interval). * @method $this subMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). * @method $this subMilli() Sub one millisecond to the instance (using date interval). * @method $this addMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using date interval). * @method $this addMillisecond() Add one millisecond to the instance (using date interval). * @method $this subMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using date interval). * @method $this subMillisecond() Sub one millisecond to the instance (using date interval). * @method $this addMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). * @method $this addMicro() Add one microsecond to the instance (using date interval). * @method $this subMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). * @method $this subMicro() Sub one microsecond to the instance (using date interval). * @method $this addMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using date interval). * @method $this addMicrosecond() Add one microsecond to the instance (using date interval). * @method $this subMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using date interval). * @method $this subMicrosecond() Sub one microsecond to the instance (using date interval). * @method $this addMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval). * @method $this addMillennium() Add one millennium to the instance (using date interval). * @method $this subMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval). * @method $this subMillennium() Sub one millennium to the instance (using date interval). * @method $this addMillenniaWithOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this addMillenniumWithOverflow() Add one millennium to the instance (using date interval) with overflow explicitly allowed. * @method $this subMillenniaWithOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this subMillenniumWithOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly allowed. * @method $this addMillenniaWithoutOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMillenniumWithoutOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMillenniaWithoutOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMillenniumWithoutOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMillenniaWithNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMillenniumWithNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMillenniaWithNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMillenniumWithNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMillenniaNoOverflow(int $value = 1) Add millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addMillenniumNoOverflow() Add one millennium to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMillenniaNoOverflow(int $value = 1) Sub millennia (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subMillenniumNoOverflow() Sub one millennium to the instance (using date interval) with overflow explicitly forbidden. * @method $this addCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval). * @method $this addCentury() Add one century to the instance (using date interval). * @method $this subCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval). * @method $this subCentury() Sub one century to the instance (using date interval). * @method $this addCenturiesWithOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this addCenturyWithOverflow() Add one century to the instance (using date interval) with overflow explicitly allowed. * @method $this subCenturiesWithOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this subCenturyWithOverflow() Sub one century to the instance (using date interval) with overflow explicitly allowed. * @method $this addCenturiesWithoutOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addCenturyWithoutOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. * @method $this subCenturiesWithoutOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subCenturyWithoutOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. * @method $this addCenturiesWithNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addCenturyWithNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. * @method $this subCenturiesWithNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subCenturyWithNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. * @method $this addCenturiesNoOverflow(int $value = 1) Add centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addCenturyNoOverflow() Add one century to the instance (using date interval) with overflow explicitly forbidden. * @method $this subCenturiesNoOverflow(int $value = 1) Sub centuries (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subCenturyNoOverflow() Sub one century to the instance (using date interval) with overflow explicitly forbidden. * @method $this addDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval). * @method $this addDecade() Add one decade to the instance (using date interval). * @method $this subDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval). * @method $this subDecade() Sub one decade to the instance (using date interval). * @method $this addDecadesWithOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this addDecadeWithOverflow() Add one decade to the instance (using date interval) with overflow explicitly allowed. * @method $this subDecadesWithOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this subDecadeWithOverflow() Sub one decade to the instance (using date interval) with overflow explicitly allowed. * @method $this addDecadesWithoutOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addDecadeWithoutOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. * @method $this subDecadesWithoutOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subDecadeWithoutOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. * @method $this addDecadesWithNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addDecadeWithNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. * @method $this subDecadesWithNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subDecadeWithNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. * @method $this addDecadesNoOverflow(int $value = 1) Add decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addDecadeNoOverflow() Add one decade to the instance (using date interval) with overflow explicitly forbidden. * @method $this subDecadesNoOverflow(int $value = 1) Sub decades (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subDecadeNoOverflow() Sub one decade to the instance (using date interval) with overflow explicitly forbidden. * @method $this addQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval). * @method $this addQuarter() Add one quarter to the instance (using date interval). * @method $this subQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval). * @method $this subQuarter() Sub one quarter to the instance (using date interval). * @method $this addQuartersWithOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this addQuarterWithOverflow() Add one quarter to the instance (using date interval) with overflow explicitly allowed. * @method $this subQuartersWithOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly allowed. * @method $this subQuarterWithOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly allowed. * @method $this addQuartersWithoutOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addQuarterWithoutOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. * @method $this subQuartersWithoutOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subQuarterWithoutOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. * @method $this addQuartersWithNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addQuarterWithNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. * @method $this subQuartersWithNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subQuarterWithNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. * @method $this addQuartersNoOverflow(int $value = 1) Add quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this addQuarterNoOverflow() Add one quarter to the instance (using date interval) with overflow explicitly forbidden. * @method $this subQuartersNoOverflow(int $value = 1) Sub quarters (the $value count passed in) to the instance (using date interval) with overflow explicitly forbidden. * @method $this subQuarterNoOverflow() Sub one quarter to the instance (using date interval) with overflow explicitly forbidden. * @method $this addWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using date interval). * @method $this addWeek() Add one week to the instance (using date interval). * @method $this subWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using date interval). * @method $this subWeek() Sub one week to the instance (using date interval). * @method $this addWeekdays(int $value = 1) Add weekdays (the $value count passed in) to the instance (using date interval). * @method $this addWeekday() Add one weekday to the instance (using date interval). * @method $this subWeekdays(int $value = 1) Sub weekdays (the $value count passed in) to the instance (using date interval). * @method $this subWeekday() Sub one weekday to the instance (using date interval). * @method $this addRealMicros(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). * @method $this addRealMicro() Add one microsecond to the instance (using timestamp). * @method $this subRealMicros(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). * @method $this subRealMicro() Sub one microsecond to the instance (using timestamp). * @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. * @method $this addRealMicroseconds(int $value = 1) Add microseconds (the $value count passed in) to the instance (using timestamp). * @method $this addRealMicrosecond() Add one microsecond to the instance (using timestamp). * @method $this subRealMicroseconds(int $value = 1) Sub microseconds (the $value count passed in) to the instance (using timestamp). * @method $this subRealMicrosecond() Sub one microsecond to the instance (using timestamp). * @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. * @method $this addRealMillis(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). * @method $this addRealMilli() Add one millisecond to the instance (using timestamp). * @method $this subRealMillis(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). * @method $this subRealMilli() Sub one millisecond to the instance (using timestamp). * @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. * @method $this addRealMilliseconds(int $value = 1) Add milliseconds (the $value count passed in) to the instance (using timestamp). * @method $this addRealMillisecond() Add one millisecond to the instance (using timestamp). * @method $this subRealMilliseconds(int $value = 1) Sub milliseconds (the $value count passed in) to the instance (using timestamp). * @method $this subRealMillisecond() Sub one millisecond to the instance (using timestamp). * @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. * @method $this addRealSeconds(int $value = 1) Add seconds (the $value count passed in) to the instance (using timestamp). * @method $this addRealSecond() Add one second to the instance (using timestamp). * @method $this subRealSeconds(int $value = 1) Sub seconds (the $value count passed in) to the instance (using timestamp). * @method $this subRealSecond() Sub one second to the instance (using timestamp). * @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. * @method $this addRealMinutes(int $value = 1) Add minutes (the $value count passed in) to the instance (using timestamp). * @method $this addRealMinute() Add one minute to the instance (using timestamp). * @method $this subRealMinutes(int $value = 1) Sub minutes (the $value count passed in) to the instance (using timestamp). * @method $this subRealMinute() Sub one minute to the instance (using timestamp). * @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. * @method $this addRealHours(int $value = 1) Add hours (the $value count passed in) to the instance (using timestamp). * @method $this addRealHour() Add one hour to the instance (using timestamp). * @method $this subRealHours(int $value = 1) Sub hours (the $value count passed in) to the instance (using timestamp). * @method $this subRealHour() Sub one hour to the instance (using timestamp). * @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. * @method $this addRealDays(int $value = 1) Add days (the $value count passed in) to the instance (using timestamp). * @method $this addRealDay() Add one day to the instance (using timestamp). * @method $this subRealDays(int $value = 1) Sub days (the $value count passed in) to the instance (using timestamp). * @method $this subRealDay() Sub one day to the instance (using timestamp). * @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. * @method $this addRealWeeks(int $value = 1) Add weeks (the $value count passed in) to the instance (using timestamp). * @method $this addRealWeek() Add one week to the instance (using timestamp). * @method $this subRealWeeks(int $value = 1) Sub weeks (the $value count passed in) to the instance (using timestamp). * @method $this subRealWeek() Sub one week to the instance (using timestamp). * @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. * @method $this addRealMonths(int $value = 1) Add months (the $value count passed in) to the instance (using timestamp). * @method $this addRealMonth() Add one month to the instance (using timestamp). * @method $this subRealMonths(int $value = 1) Sub months (the $value count passed in) to the instance (using timestamp). * @method $this subRealMonth() Sub one month to the instance (using timestamp). * @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. * @method $this addRealQuarters(int $value = 1) Add quarters (the $value count passed in) to the instance (using timestamp). * @method $this addRealQuarter() Add one quarter to the instance (using timestamp). * @method $this subRealQuarters(int $value = 1) Sub quarters (the $value count passed in) to the instance (using timestamp). * @method $this subRealQuarter() Sub one quarter to the instance (using timestamp). * @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. * @method $this addRealYears(int $value = 1) Add years (the $value count passed in) to the instance (using timestamp). * @method $this addRealYear() Add one year to the instance (using timestamp). * @method $this subRealYears(int $value = 1) Sub years (the $value count passed in) to the instance (using timestamp). * @method $this subRealYear() Sub one year to the instance (using timestamp). * @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. * @method $this addRealDecades(int $value = 1) Add decades (the $value count passed in) to the instance (using timestamp). * @method $this addRealDecade() Add one decade to the instance (using timestamp). * @method $this subRealDecades(int $value = 1) Sub decades (the $value count passed in) to the instance (using timestamp). * @method $this subRealDecade() Sub one decade to the instance (using timestamp). * @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. * @method $this addRealCenturies(int $value = 1) Add centuries (the $value count passed in) to the instance (using timestamp). * @method $this addRealCentury() Add one century to the instance (using timestamp). * @method $this subRealCenturies(int $value = 1) Sub centuries (the $value count passed in) to the instance (using timestamp). * @method $this subRealCentury() Sub one century to the instance (using timestamp). * @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. * @method $this addRealMillennia(int $value = 1) Add millennia (the $value count passed in) to the instance (using timestamp). * @method $this addRealMillennium() Add one millennium to the instance (using timestamp). * @method $this subRealMillennia(int $value = 1) Sub millennia (the $value count passed in) to the instance (using timestamp). * @method $this subRealMillennium() Sub one millennium to the instance (using timestamp). * @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. * @method $this roundYear(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. * @method $this roundYears(float $precision = 1, string $function = "round") Round the current instance year with given precision using the given function. * @method $this floorYear(float $precision = 1) Truncate the current instance year with given precision. * @method $this floorYears(float $precision = 1) Truncate the current instance year with given precision. * @method $this ceilYear(float $precision = 1) Ceil the current instance year with given precision. * @method $this ceilYears(float $precision = 1) Ceil the current instance year with given precision. * @method $this roundMonth(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function. * @method $this roundMonths(float $precision = 1, string $function = "round") Round the current instance month with given precision using the given function. * @method $this floorMonth(float $precision = 1) Truncate the current instance month with given precision. * @method $this floorMonths(float $precision = 1) Truncate the current instance month with given precision. * @method $this ceilMonth(float $precision = 1) Ceil the current instance month with given precision. * @method $this ceilMonths(float $precision = 1) Ceil the current instance month with given precision. * @method $this roundDay(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function. * @method $this roundDays(float $precision = 1, string $function = "round") Round the current instance day with given precision using the given function. * @method $this floorDay(float $precision = 1) Truncate the current instance day with given precision. * @method $this floorDays(float $precision = 1) Truncate the current instance day with given precision. * @method $this ceilDay(float $precision = 1) Ceil the current instance day with given precision. * @method $this ceilDays(float $precision = 1) Ceil the current instance day with given precision. * @method $this roundHour(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function. * @method $this roundHours(float $precision = 1, string $function = "round") Round the current instance hour with given precision using the given function. * @method $this floorHour(float $precision = 1) Truncate the current instance hour with given precision. * @method $this floorHours(float $precision = 1) Truncate the current instance hour with given precision. * @method $this ceilHour(float $precision = 1) Ceil the current instance hour with given precision. * @method $this ceilHours(float $precision = 1) Ceil the current instance hour with given precision. * @method $this roundMinute(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function. * @method $this roundMinutes(float $precision = 1, string $function = "round") Round the current instance minute with given precision using the given function. * @method $this floorMinute(float $precision = 1) Truncate the current instance minute with given precision. * @method $this floorMinutes(float $precision = 1) Truncate the current instance minute with given precision. * @method $this ceilMinute(float $precision = 1) Ceil the current instance minute with given precision. * @method $this ceilMinutes(float $precision = 1) Ceil the current instance minute with given precision. * @method $this roundSecond(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function. * @method $this roundSeconds(float $precision = 1, string $function = "round") Round the current instance second with given precision using the given function. * @method $this floorSecond(float $precision = 1) Truncate the current instance second with given precision. * @method $this floorSeconds(float $precision = 1) Truncate the current instance second with given precision. * @method $this ceilSecond(float $precision = 1) Ceil the current instance second with given precision. * @method $this ceilSeconds(float $precision = 1) Ceil the current instance second with given precision. * @method $this roundMillennium(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function. * @method $this roundMillennia(float $precision = 1, string $function = "round") Round the current instance millennium with given precision using the given function. * @method $this floorMillennium(float $precision = 1) Truncate the current instance millennium with given precision. * @method $this floorMillennia(float $precision = 1) Truncate the current instance millennium with given precision. * @method $this ceilMillennium(float $precision = 1) Ceil the current instance millennium with given precision. * @method $this ceilMillennia(float $precision = 1) Ceil the current instance millennium with given precision. * @method $this roundCentury(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function. * @method $this roundCenturies(float $precision = 1, string $function = "round") Round the current instance century with given precision using the given function. * @method $this floorCentury(float $precision = 1) Truncate the current instance century with given precision. * @method $this floorCenturies(float $precision = 1) Truncate the current instance century with given precision. * @method $this ceilCentury(float $precision = 1) Ceil the current instance century with given precision. * @method $this ceilCenturies(float $precision = 1) Ceil the current instance century with given precision. * @method $this roundDecade(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function. * @method $this roundDecades(float $precision = 1, string $function = "round") Round the current instance decade with given precision using the given function. * @method $this floorDecade(float $precision = 1) Truncate the current instance decade with given precision. * @method $this floorDecades(float $precision = 1) Truncate the current instance decade with given precision. * @method $this ceilDecade(float $precision = 1) Ceil the current instance decade with given precision. * @method $this ceilDecades(float $precision = 1) Ceil the current instance decade with given precision. * @method $this roundQuarter(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function. * @method $this roundQuarters(float $precision = 1, string $function = "round") Round the current instance quarter with given precision using the given function. * @method $this floorQuarter(float $precision = 1) Truncate the current instance quarter with given precision. * @method $this floorQuarters(float $precision = 1) Truncate the current instance quarter with given precision. * @method $this ceilQuarter(float $precision = 1) Ceil the current instance quarter with given precision. * @method $this ceilQuarters(float $precision = 1) Ceil the current instance quarter with given precision. * @method $this roundMillisecond(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function. * @method $this roundMilliseconds(float $precision = 1, string $function = "round") Round the current instance millisecond with given precision using the given function. * @method $this floorMillisecond(float $precision = 1) Truncate the current instance millisecond with given precision. * @method $this floorMilliseconds(float $precision = 1) Truncate the current instance millisecond with given precision. * @method $this ceilMillisecond(float $precision = 1) Ceil the current instance millisecond with given precision. * @method $this ceilMilliseconds(float $precision = 1) Ceil the current instance millisecond with given precision. * @method $this roundMicrosecond(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function. * @method $this roundMicroseconds(float $precision = 1, string $function = "round") Round the current instance microsecond with given precision using the given function. * @method $this floorMicrosecond(float $precision = 1) Truncate the current instance microsecond with given precision. * @method $this floorMicroseconds(float $precision = 1) Truncate the current instance microsecond with given precision. * @method $this ceilMicrosecond(float $precision = 1) Ceil the current instance microsecond with given precision. * @method $this ceilMicroseconds(float $precision = 1) Ceil the current instance microsecond with given precision. * @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.) * @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.) * @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.) * @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.) * @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.) * @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.) * @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.) * @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.) * * */ interface CarbonInterface extends DateTimeInterface, JsonSerializable { /** * Diff wording options(expressed in octal). */ public const NO_ZERO_DIFF = 01; public const JUST_NOW = 02; public const ONE_DAY_WORDS = 04; public const TWO_DAY_WORDS = 010; public const SEQUENTIAL_PARTS_ONLY = 020; /** * Diff syntax options. */ public const DIFF_ABSOLUTE = 1; // backward compatibility with true public const DIFF_RELATIVE_AUTO = 0; // backward compatibility with false public const DIFF_RELATIVE_TO_NOW = 2; public const DIFF_RELATIVE_TO_OTHER = 3; /** * Translate string options. */ public const TRANSLATE_MONTHS = 1; public const TRANSLATE_DAYS = 2; public const TRANSLATE_UNITS = 4; public const TRANSLATE_MERIDIEM = 8; public const TRANSLATE_ALL = self::TRANSLATE_MONTHS | self::TRANSLATE_DAYS | self::TRANSLATE_UNITS | self::TRANSLATE_MERIDIEM; /** * The day constants. */ public const SUNDAY = 0; public const MONDAY = 1; public const TUESDAY = 2; public const WEDNESDAY = 3; public const THURSDAY = 4; public const FRIDAY = 5; public const SATURDAY = 6; /** * Number of X in Y. */ public const YEARS_PER_MILLENNIUM = 1000; public const YEARS_PER_CENTURY = 100; public const YEARS_PER_DECADE = 10; public const MONTHS_PER_YEAR = 12; public const MONTHS_PER_QUARTER = 3; public const WEEKS_PER_YEAR = 52; public const WEEKS_PER_MONTH = 4; public const DAYS_PER_WEEK = 7; public const HOURS_PER_DAY = 24; public const MINUTES_PER_HOUR = 60; public const SECONDS_PER_MINUTE = 60; public const MILLISECONDS_PER_SECOND = 1000; public const MICROSECONDS_PER_MILLISECOND = 1000; public const MICROSECONDS_PER_SECOND = 1000000; /** * RFC7231 DateTime format. * * @var string */ public const RFC7231_FORMAT = 'D, d M Y H:i:s \G\M\T'; /** * Default format to use for __toString method when type juggling occurs. * * @var string */ public const DEFAULT_TO_STRING_FORMAT = 'Y-m-d H:i:s'; /** * Format for converting mocked time, includes microseconds. * * @var string */ public const MOCK_DATETIME_FORMAT = 'Y-m-d H:i:s.u'; /** * Pattern detection for ->isoFormat and ::createFromIsoFormat. * * @var string */ 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?)'; // /** * Dynamically handle calls to the class. * * @param string $method magic method name called * @param array $parameters parameters list * * @throws \BadMethodCallException|\ReflectionException * * @return mixed */ public function __call($method, $parameters); /** * Dynamically handle calls to the class. * * @param string $method magic method name called * @param array $parameters parameters list * * @throws \BadMethodCallException * * @return mixed */ public static function __callStatic($method, $parameters); /** * Create a new Carbon instance. * * Please see the testing aids section (specifically static::setTestNow()) * for more on the possibility of this constructor returning a test instance. * * @param string|null $time * @param \DateTimeZone|string|null $tz */ public function __construct($time = null, $tz = null); /** * Show truthy properties on var_dump(). * * @return array */ public function __debugInfo(); /** * Get a part of the Carbon object * * @param string $name * * @throws InvalidArgumentException|ReflectionException * * @return string|int|bool|\DateTimeZone|null */ public function __get($name); /** * Check if an attribute exists on the object * * @param string $name * * @return bool */ public function __isset($name); /** * Set a part of the Carbon object * * @param string $name * @param string|int|\DateTimeZone $value * * @throws InvalidArgumentException|ReflectionException * * @return void */ public function __set($name, $value); /** * The __set_state handler. * * @param string|array $dump * * @return static */ public static function __set_state($dump); /** * Returns the list of properties to dump on serialize() called on. * * @return array */ public function __sleep(); /** * Format the instance as a string using the set format * * @example * ``` * echo Carbon::now(); // Carbon instances can be casted to string * ``` * * @return string */ public function __toString(); /** * Add given units or interval to the current instance. * * @example $date->add('hour', 3) * @example $date->add(15, 'days') * @example $date->add(CarbonInterval::days(4)) * * @param string|DateInterval $unit * @param int $value * @param bool|null $overflow * * @return CarbonInterface */ public function add($unit, $value = 1, $overflow = null); /** * Add seconds to the instance using timestamp. Positive $value travels * forward while negative $value travels into the past. * * @param string $unit * @param int $value * * @return static */ public function addRealUnit($unit, $value = 1); /** * Add given units to the current instance. * * @param string $unit * @param int $value * @param bool|null $overflow * * @return CarbonInterface */ public function addUnit($unit, $value = 1, $overflow = null); /** * Add any unit to a new value without overflowing current other unit given. * * @param string $valueUnit unit name to modify * @param int $value amount to add to the input unit * @param string $overflowUnit unit name to not overflow * * @return static */ public function addUnitNoOverflow($valueUnit, $value, $overflowUnit); /** * Get the difference in a human readable format in the current locale from an other * instance given to now * * @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains: * - 'syntax' entry (see below) * - 'short' entry (see below) * - 'parts' entry (see below) * - 'options' entry (see below) * - 'join' entry determines how to join multiple parts of the string * ` - if $join is a string, it's used as a joiner glue * ` - if $join is a callable/closure, it get the list of string and should return a string * ` - if $join is an array, the first item will be the default glue, and the second item * ` will be used instead of the glue for the last item * ` - if $join is true, it will be guessed from the locale ('list' translation file entry) * ` - if $join is missing, a space will be used as glue * if int passed, it add modifiers: * Possible values: * - CarbonInterface::DIFF_ABSOLUTE no modifiers * - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier * - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier * Default value: CarbonInterface::DIFF_ABSOLUTE * @param bool $short displays short format of time units * @param int $parts maximum number of parts to display (default value: 1: single part) * @param int $options human diff options * * @return string */ public function ago($syntax = null, $short = false, $parts = 1, $options = null); /** * Modify the current instance to the average of a given instance (default now) and the current instance * (second-precision). * * @param \Carbon\Carbon|\DateTimeInterface|null $date * * @return static */ public function average($date = null); /** * Determines if the instance is between two others * * @example * ``` * Carbon::parse('2018-07-25')->between('2018-07-14', '2018-08-01'); // true * Carbon::parse('2018-07-25')->between('2018-08-01', '2018-08-20'); // false * Carbon::parse('2018-07-25')->between('2018-07-25', '2018-08-01'); // false * Carbon::parse('2018-07-25')->between('2018-07-25', '2018-08-01', true); // true * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date1 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date2 * @param bool $equal Indicates if an equal to comparison should be done * * @return bool */ public function between($date1, $date2, $equal = true): bool; /** * Returns either the close date "Friday 15h30", or a calendar date "10/09/2017" is farthest than 7 days from now. * * @param Carbon|\DateTimeInterface|string|null $referenceTime * @param array $formats * * @return string */ public function calendar($referenceTime = null, array $formats = []); /** * Cast the current instance into the given class. * * @param string $className The $className::instance() method will be called to cast the current object. * * @return object */ public function cast(string $className); /** * Ceil the current instance second with given precision if specified. * * @param float|int $precision * * @return CarbonInterface */ public function ceil($precision = 1); /** * Ceil the current instance at the given unit with given precision if specified. * * @param string $unit * @param float|int $precision * * @return CarbonInterface */ public function ceilUnit($unit, $precision = 1); /** * Ceil the current instance week. * * @param int $weekStartsAt optional start allow you to specify the day of week to use to start the week * * @return CarbonInterface */ public function ceilWeek($weekStartsAt = null); /** * Similar to native modify() method of DateTime but can handle more grammars. * * @example * ``` * echo Carbon::now()->change('next 2pm'); * ``` * * @link https://php.net/manual/en/datetime.modify.php * * @param string $modifier * * @return static */ public function change($modifier); /** * @alias copy * * Get a copy of the instance. * * @return static */ public function clone(); /** * Get the closest date from the instance (second-precision). * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date1 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date2 * * @return static */ public function closest($date1, $date2); /** * Get a copy of the instance. * * @return static */ public function copy(); /** * Create a new Carbon instance from a specific date and time. * * If any of $year, $month or $day are set to null their now() values will * be used. * * If $hour is null it will be set to its now() value and the default * values for $minute and $second will be their now() values. * * If $hour is not null then the default values for $minute and $second * will be 0. * * @param int|null $year * @param int|null $month * @param int|null $day * @param int|null $hour * @param int|null $minute * @param int|null $second * @param \DateTimeZone|string|null $tz * * @throws \InvalidArgumentException * * @return static */ public static function create($year = 0, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0, $tz = null); /** * Create a Carbon instance from just a date. The time portion is set to now. * * @param int|null $year * @param int|null $month * @param int|null $day * @param \DateTimeZone|string|null $tz * * @throws \InvalidArgumentException * * @return static */ public static function createFromDate($year = null, $month = null, $day = null, $tz = null); /** * Create a Carbon instance from a specific format. * * @param string $format Datetime format * @param string $time * @param \DateTimeZone|string|false|null $tz * * @throws InvalidArgumentException * * @return static|false */ public static function createFromFormat($format, $time, $tz = null); /** * Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()). * * @param string $format Datetime format * @param string $time * @param \DateTimeZone|string|false|null $tz optional timezone * @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) * @param \Symfony\Component\Translation\TranslatorInterface $translator optional custom translator to use for macro-formats * * @throws InvalidArgumentException * * @return static|false */ public static function createFromIsoFormat($format, $time, $tz = null, $locale = 'en', $translator = null); /** * Create a Carbon instance from a specific format and a string in a given language. * * @param string $format Datetime format * @param string $locale * @param string $time * @param \DateTimeZone|string|false|null $tz * * @throws InvalidArgumentException * * @return static|false */ public static function createFromLocaleFormat($format, $locale, $time, $tz = null); /** * Create a Carbon instance from a specific ISO format and a string in a given language. * * @param string $format Datetime ISO format * @param string $locale * @param string $time * @param \DateTimeZone|string|false|null $tz * * @throws InvalidArgumentException * * @return static|false */ public static function createFromLocaleIsoFormat($format, $locale, $time, $tz = null); /** * Create a Carbon instance from just a time. The date portion is set to today. * * @param int|null $hour * @param int|null $minute * @param int|null $second * @param \DateTimeZone|string|null $tz * * @throws \InvalidArgumentException * * @return static */ public static function createFromTime($hour = 0, $minute = 0, $second = 0, $tz = null); /** * Create a Carbon instance from a time string. The date portion is set to today. * * @param string $time * @param \DateTimeZone|string|null $tz * * @throws \InvalidArgumentException * * @return static */ public static function createFromTimeString($time, $tz = null); /** * Create a Carbon instance from a timestamp. * * @param int $timestamp * @param \DateTimeZone|string|null $tz * * @return static */ public static function createFromTimestamp($timestamp, $tz = null); /** * Create a Carbon instance from a timestamp in milliseconds. * * @param int $timestamp * @param \DateTimeZone|string|null $tz * * @return static */ public static function createFromTimestampMs($timestamp, $tz = null); /** * Create a Carbon instance from an UTC timestamp. * * @param int $timestamp * * @return static */ public static function createFromTimestampUTC($timestamp); /** * Create a Carbon instance from just a date. The time portion is set to midnight. * * @param int|null $year * @param int|null $month * @param int|null $day * @param \DateTimeZone|string|null $tz * * @return static */ public static function createMidnightDate($year = null, $month = null, $day = null, $tz = null); /** * Create a new safe Carbon instance from a specific date and time. * * If any of $year, $month or $day are set to null their now() values will * be used. * * If $hour is null it will be set to its now() value and the default * values for $minute and $second will be their now() values. * * If $hour is not null then the default values for $minute and $second * will be 0. * * If one of the set values is not valid, an \InvalidArgumentException * will be thrown. * * @param int|null $year * @param int|null $month * @param int|null $day * @param int|null $hour * @param int|null $minute * @param int|null $second * @param \DateTimeZone|string|null $tz * * @throws \Carbon\Exceptions\InvalidDateException|\InvalidArgumentException * * @return static|false */ public static function createSafe($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null); /** * Get/set the day of year. * * @param int|null $value new value for day of year if using as setter. * * @return static|int */ public function dayOfYear($value = null); /** * Get the difference as a CarbonInterval instance * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return CarbonInterval */ public function diffAsCarbonInterval($date = null, $absolute = true); /** * Get the difference by the given interval using a filter closure * * @param CarbonInterval $ci An interval to traverse by * @param Closure $callback * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffFiltered(CarbonInterval $ci, \Closure $callback, $date = null, $absolute = true); /** * Get the difference in a human readable format in the current locale from current instance to an other * instance given (or now if null given). * * @example * ``` * echo Carbon::tomorrow()->diffForHumans() . "\n"; * echo Carbon::tomorrow()->diffForHumans(['parts' => 2]) . "\n"; * echo Carbon::tomorrow()->diffForHumans(['parts' => 3, 'join' => true]) . "\n"; * echo Carbon::tomorrow()->diffForHumans(Carbon::yesterday()) . "\n"; * echo Carbon::tomorrow()->diffForHumans(Carbon::yesterday(), ['short' => true]) . "\n"; * ``` * * @param Carbon|\DateTimeInterface|string|array|null $other if array passed, will be used as parameters array, see $syntax below; * if null passed, now will be used as comparison reference; * if any other type, it will be converted to date and used as reference. * @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains: * - 'syntax' entry (see below) * - 'short' entry (see below) * - 'parts' entry (see below) * - 'options' entry (see below) * - 'join' entry determines how to join multiple parts of the string * ` - if $join is a string, it's used as a joiner glue * ` - if $join is a callable/closure, it get the list of string and should return a string * ` - if $join is an array, the first item will be the default glue, and the second item * ` will be used instead of the glue for the last item * ` - if $join is true, it will be guessed from the locale ('list' translation file entry) * ` - if $join is missing, a space will be used as glue * - 'other' entry (see above) * if int passed, it add modifiers: * Possible values: * - CarbonInterface::DIFF_ABSOLUTE no modifiers * - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier * - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier * Default value: CarbonInterface::DIFF_ABSOLUTE * @param bool $short displays short format of time units * @param int $parts maximum number of parts to display (default value: 1: single unit) * @param int $options human diff options * * @return string */ public function diffForHumans($other = null, $syntax = null, $short = false, $parts = 1, $options = null); /** * Get the difference in days * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInDays($date = null, $absolute = true); /** * Get the difference in days using a filter closure * * @param Closure $callback * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInDaysFiltered(\Closure $callback, $date = null, $absolute = true); /** * Get the difference in hours. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInHours($date = null, $absolute = true); /** * Get the difference in hours using a filter closure * * @param Closure $callback * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInHoursFiltered(\Closure $callback, $date = null, $absolute = true); /** * Get the difference in microseconds. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInMicroseconds($date = null, $absolute = true); /** * Get the difference in milliseconds. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInMilliseconds($date = null, $absolute = true); /** * Get the difference in minutes. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInMinutes($date = null, $absolute = true); /** * Get the difference in months * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInMonths($date = null, $absolute = true); /** * Get the difference in hours using timestamps. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInRealHours($date = null, $absolute = true); /** * Get the difference in microseconds using timestamps. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInRealMicroseconds($date = null, $absolute = true); /** * Get the difference in milliseconds using timestamps. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInRealMilliseconds($date = null, $absolute = true); /** * Get the difference in minutes using timestamps. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInRealMinutes($date = null, $absolute = true); /** * Get the difference in seconds using timestamps. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInRealSeconds($date = null, $absolute = true); /** * Get the difference in seconds. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInSeconds($date = null, $absolute = true); /** * Get the difference in weekdays * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInWeekdays($date = null, $absolute = true); /** * Get the difference in weekend days using a filter * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInWeekendDays($date = null, $absolute = true); /** * Get the difference in weeks * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInWeeks($date = null, $absolute = true); /** * Get the difference in years * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return int */ public function diffInYears($date = null, $absolute = true); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather use the ->settings() method. * @see settings * * @param int $humanDiffOption */ public static function disableHumanDiffOption($humanDiffOption); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather use the ->settings() method. * @see settings * * @param int $humanDiffOption */ public static function enableHumanDiffOption($humanDiffOption); /** * Modify to end of current given unit. * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16.334455') * ->startOf('month') * ->endOf('week', Carbon::FRIDAY); * ``` * * @param string $unit * @param array $params * * @return static */ public function endOf($unit, ...$params); /** * Resets the date to end of the century and time to 23:59:59.999999 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->endOfCentury(); * ``` * * @return static */ public function endOfCentury(); /** * Resets the time to 23:59:59.999999 end of day * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->endOfDay(); * ``` * * @return static */ public function endOfDay(); /** * Resets the date to end of the decade and time to 23:59:59.999999 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->endOfDecade(); * ``` * * @return static */ public function endOfDecade(); /** * Modify to end of current hour, minutes and seconds become 59 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->endOfHour(); * ``` * * @return static */ public function endOfHour(); /** * Resets the date to end of the century and time to 23:59:59.999999 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->endOfMillennium(); * ``` * * @return static */ public function endOfMillennium(); /** * Modify to end of current minute, seconds become 59 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->endOfMinute(); * ``` * * @return static */ public function endOfMinute(); /** * Resets the date to end of the month and time to 23:59:59.999999 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->endOfMonth(); * ``` * * @return static */ public function endOfMonth(); /** * Resets the date to end of the quarter and time to 23:59:59.999999 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->endOfQuarter(); * ``` * * @return static */ public function endOfQuarter(); /** * Modify to end of current second, microseconds become 999999 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16.334455') * ->endOfSecond() * ->format('H:i:s.u'); * ``` * * @return static */ public function endOfSecond(); /** * Resets the date to end of week (defined in $weekEndsAt) and time to 23:59:59.999999 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->endOfWeek() . "\n"; * echo Carbon::parse('2018-07-25 12:45:16')->locale('ar')->endOfWeek() . "\n"; * echo Carbon::parse('2018-07-25 12:45:16')->endOfWeek(Carbon::SATURDAY) . "\n"; * ``` * * @param int $weekEndsAt optional start allow you to specify the day of week to use to end the week * * @return static */ public function endOfWeek($weekEndsAt = null); /** * Resets the date to end of the year and time to 23:59:59.999999 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->endOfYear(); * ``` * * @return static */ public function endOfYear(); /** * Determines if the instance is equal to another * * @example * ``` * Carbon::parse('2018-07-25 12:45:16')->eq('2018-07-25 12:45:16'); // true * Carbon::parse('2018-07-25 12:45:16')->eq(Carbon::parse('2018-07-25 12:45:16')); // true * Carbon::parse('2018-07-25 12:45:16')->eq('2018-07-25 12:45:17'); // false * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see equalTo() * * @return bool */ public function eq($date): bool; /** * Determines if the instance is equal to another * * @example * ``` * Carbon::parse('2018-07-25 12:45:16')->equalTo('2018-07-25 12:45:16'); // true * Carbon::parse('2018-07-25 12:45:16')->equalTo(Carbon::parse('2018-07-25 12:45:16')); // true * Carbon::parse('2018-07-25 12:45:16')->equalTo('2018-07-25 12:45:17'); // false * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @return bool */ public function equalTo($date): bool; /** * Set the current locale to the given, execute the passed function, reset the locale to previous one, * then return the result of the closure (or null if the closure was void). * * @param string $locale locale ex. en * @param callable $func * * @return mixed */ public static function executeWithLocale($locale, $func); /** * Get the farthest date from the instance (second-precision). * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date1 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date2 * * @return static */ public function farthest($date1, $date2); /** * Modify to the first occurrence of a given day of the week * in the current month. If no dayOfWeek is provided, modify to the * first day of the current month. Use the supplied constants * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int|null $dayOfWeek * * @return static */ public function firstOfMonth($dayOfWeek = null); /** * Modify to the first occurrence of a given day of the week * in the current quarter. If no dayOfWeek is provided, modify to the * first day of the current quarter. Use the supplied constants * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int|null $dayOfWeek day of the week default null * * @return static */ public function firstOfQuarter($dayOfWeek = null); /** * Modify to the first occurrence of a given day of the week * in the current year. If no dayOfWeek is provided, modify to the * first day of the current year. Use the supplied constants * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int|null $dayOfWeek day of the week default null * * @return static */ public function firstOfYear($dayOfWeek = null); /** * Get the difference in days as float (microsecond-precision). * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return float */ public function floatDiffInDays($date = null, $absolute = true); /** * Get the difference in hours as float (microsecond-precision). * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return float */ public function floatDiffInHours($date = null, $absolute = true); /** * Get the difference in minutes as float (microsecond-precision). * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return float */ public function floatDiffInMinutes($date = null, $absolute = true); /** * Get the difference in months as float (microsecond-precision). * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return float */ public function floatDiffInMonths($date = null, $absolute = true); /** * Get the difference in days as float (microsecond-precision). * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return float */ public function floatDiffInRealDays($date = null, $absolute = true); /** * Get the difference in hours as float (microsecond-precision) using timestamps. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return float */ public function floatDiffInRealHours($date = null, $absolute = true); /** * Get the difference in minutes as float (microsecond-precision) using timestamps. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return float */ public function floatDiffInRealMinutes($date = null, $absolute = true); /** * Get the difference in months as float (microsecond-precision) using timestamps. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return float */ public function floatDiffInRealMonths($date = null, $absolute = true); /** * Get the difference in seconds as float (microsecond-precision) using timestamps. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return float */ public function floatDiffInRealSeconds($date = null, $absolute = true); /** * Get the difference in year as float (microsecond-precision) using timestamps. * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return float */ public function floatDiffInRealYears($date = null, $absolute = true); /** * Get the difference in seconds as float (microsecond-precision). * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return float */ public function floatDiffInSeconds($date = null, $absolute = true); /** * Get the difference in year as float (microsecond-precision). * * @param \Carbon\CarbonInterface|\DateTimeInterface|string|null $date * @param bool $absolute Get the absolute of the difference * * @return float */ public function floatDiffInYears($date = null, $absolute = true); /** * Round the current instance second with given precision if specified. * * @param float|int $precision * * @return CarbonInterface */ public function floor($precision = 1); /** * Truncate the current instance at the given unit with given precision if specified. * * @param string $unit * @param float|int $precision * * @return CarbonInterface */ public function floorUnit($unit, $precision = 1); /** * Truncate the current instance week. * * @param int $weekStartsAt optional start allow you to specify the day of week to use to start the week * * @return CarbonInterface */ public function floorWeek($weekStartsAt = null); /** * Format the instance with the current locale. You can set the current * locale using setlocale() http://php.net/setlocale. * * @param string $format * * @return string */ public function formatLocalized($format); /** * @alias diffForHumans * * Get the difference in a human readable format in the current locale from current instance to an other * instance given (or now if null given). * * @param Carbon|\DateTimeInterface|string|array|null $other if array passed, will be used as parameters array, see $syntax below; * if null passed, now will be used as comparison reference; * if any other type, it will be converted to date and used as reference. * @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains: * - 'syntax' entry (see below) * - 'short' entry (see below) * - 'parts' entry (see below) * - 'options' entry (see below) * - 'join' entry determines how to join multiple parts of the string * ` - if $join is a string, it's used as a joiner glue * ` - if $join is a callable/closure, it get the list of string and should return a string * ` - if $join is an array, the first item will be the default glue, and the second item * ` will be used instead of the glue for the last item * ` - if $join is true, it will be guessed from the locale ('list' translation file entry) * ` - if $join is missing, a space will be used as glue * - 'other' entry (see above) * if int passed, it add modifiers: * Possible values: * - CarbonInterface::DIFF_ABSOLUTE no modifiers * - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier * - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier * Default value: CarbonInterface::DIFF_ABSOLUTE * @param bool $short displays short format of time units * @param int $parts maximum number of parts to display (default value: 1: single unit) * @param int $options human diff options * * @return string */ public function from($other = null, $syntax = null, $short = false, $parts = 1, $options = null); /** * Get the difference in a human readable format in the current locale from current * instance to now. * * @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains: * - 'syntax' entry (see below) * - 'short' entry (see below) * - 'parts' entry (see below) * - 'options' entry (see below) * - 'join' entry determines how to join multiple parts of the string * ` - if $join is a string, it's used as a joiner glue * ` - if $join is a callable/closure, it get the list of string and should return a string * ` - if $join is an array, the first item will be the default glue, and the second item * ` will be used instead of the glue for the last item * ` - if $join is true, it will be guessed from the locale ('list' translation file entry) * ` - if $join is missing, a space will be used as glue * if int passed, it add modifiers: * Possible values: * - CarbonInterface::DIFF_ABSOLUTE no modifiers * - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier * - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier * Default value: CarbonInterface::DIFF_ABSOLUTE * @param bool $short displays short format of time units * @param int $parts maximum number of parts to display (default value: 1: single unit) * @param int $options human diff options * * @return string */ public function fromNow($syntax = null, $short = false, $parts = 1, $options = null); /** * Create an instance from a serialized string. * * @param string $value * * @throws \InvalidArgumentException * * @return static */ public static function fromSerialized($value); /** * Register a custom macro. * * @param object|callable $macro * @param int $priority marco with higher priority is tried first * * @return void */ public static function genericMacro($macro, $priority = 0); /** * Get a part of the Carbon object * * @param string $name * * @throws InvalidArgumentException|ReflectionException * * @return string|int|bool|\DateTimeZone|null */ public function get($name); /** * Returns the alternative number if available in the current locale. * * @param string $key date property * * @return string */ public function getAltNumber(string $key): string; /** * Returns the list of internally available locales and already loaded custom locales. * (It will ignore custom translator dynamic loading.) * * @return array */ public static function getAvailableLocales(); /** * Returns list of Language object for each available locale. This object allow you to get the ISO name, native * name, region and variant of the locale. * * @return Language[] */ public static function getAvailableLocalesInfo(); /** * Returns list of calendar formats for ISO formatting. * * @param string|null $locale current locale used if null * * @return array */ public function getCalendarFormats($locale = null); /** * Get the days of the week * * @return array */ public static function getDays(); /** * Get the fallback locale. * * @see https://symfony.com/doc/current/components/translation.html#fallback-locales * * @return string|null */ public static function getFallbackLocale(); /** * List of replacements from date() format to isoFormat(). * * @return array */ public static function getFormatsToIsoReplacements(); /** * Return default humanDiff() options (merged flags as integer). * * @return int */ public static function getHumanDiffOptions(); /** * Returns list of locale formats for ISO formatting. * * @param string|null $locale current locale used if null * * @return array */ public function getIsoFormats($locale = null); /** * Returns list of locale units for ISO formatting. * * @return array */ public static function getIsoUnits(); /** * {@inheritdoc} */ public static function getLastErrors(); /** * Get the translator of the current instance or the default if none set. * * @return \Symfony\Component\Translation\TranslatorInterface */ public function getLocalTranslator(); /** * Get the current translator locale. * * @return string */ public static function getLocale(); /** * get midday/noon hour * * @return int */ public static function getMidDayAt(); /** * Returns the offset hour and minute formatted with +/- and a given separator (":" by default). * For example, if the time zone is 9 hours 30 minutes, you'll get "+09:30", with "@@" as first * argument, "+09@@30", with "" as first argument, "+0930". Negative offset will return something * like "-12:00". * * @param string $separator string to place between hours and minutes (":" by default) * * @return string */ public function getOffsetString($separator = ':'); /** * Returns a unit of the instance padded with 0 by default or any other string if specified. * * @param string $unit Carbon unit name * @param int $length Length of the output (2 by default) * @param string $padString String to use for padding ("0" by default) * @param int $padType Side(s) to pad (STR_PAD_LEFT by default) * * @return string */ public function getPaddedUnit($unit, $length = 2, $padString = '0', $padType = 0); /** * Returns a timestamp rounded with the given precision (6 by default). * * @example getPreciseTimestamp() 1532087464437474 (microsecond maximum precision) * @example getPreciseTimestamp(6) 1532087464437474 * @example getPreciseTimestamp(5) 153208746443747 (1/100000 second precision) * @example getPreciseTimestamp(4) 15320874644375 (1/10000 second precision) * @example getPreciseTimestamp(3) 1532087464437 (millisecond precision) * @example getPreciseTimestamp(2) 153208746444 (1/100 second precision) * @example getPreciseTimestamp(1) 15320874644 (1/10 second precision) * @example getPreciseTimestamp(0) 1532087464 (second precision) * @example getPreciseTimestamp(-1) 153208746 (10 second precision) * @example getPreciseTimestamp(-2) 15320875 (100 second precision) * * @param int $precision * * @return float */ public function getPreciseTimestamp($precision = 6); /** * Returns current local settings. * * @return array */ public function getSettings(); /** * Get the Carbon instance (real or mock) to be returned when a "now" * instance is created. * * @return static the current instance used for testing */ public static function getTestNow(); /** * Get the translation of the current week day name (with context for languages with multiple forms). * * @param string|null $context whole format string * @param string $keySuffix "", "_short" or "_min" * @param string|null $defaultValue default value if translation missing * * @return string */ public function getTranslatedDayName($context = null, $keySuffix = '', $defaultValue = null); /** * Get the translation of the current abbreviated week day name (with context for languages with multiple forms). * * @param string|null $context whole format string * * @return string */ public function getTranslatedMinDayName($context = null); /** * Get the translation of the current month day name (with context for languages with multiple forms). * * @param string|null $context whole format string * @param string $keySuffix "" or "_short" * @param string|null $defaultValue default value if translation missing * * @return string */ public function getTranslatedMonthName($context = null, $keySuffix = '', $defaultValue = null); /** * Get the translation of the current short week day name (with context for languages with multiple forms). * * @param string|null $context whole format string * * @return string */ public function getTranslatedShortDayName($context = null); /** * Get the translation of the current short month day name (with context for languages with multiple forms). * * @param string|null $context whole format string * * @return string */ public function getTranslatedShortMonthName($context = null); /** * Returns raw translation message for a given key. * * @param string $key key to find * @param string|null $locale current locale used if null * @param string|null $default default value if translation returns the key * @param \Symfony\Component\Translation\TranslatorInterface $translator an optional translator to use * * @return string */ public function getTranslationMessage(string $key, string $locale = null, string $default = null, $translator = null); /** * Returns raw translation message for a given key. * * @param \Symfony\Component\Translation\TranslatorInterface $translator the translator to use * @param string $key key to find * @param string|null $locale current locale used if null * @param string|null $default default value if translation returns the key * * @return string */ public static function getTranslationMessageWith($translator, string $key, string $locale = null, string $default = null); /** * Get the default translator instance in use. * * @return \Symfony\Component\Translation\TranslatorInterface */ public static function getTranslator(); /** * Get the last day of week * * @return int */ public static function getWeekEndsAt(); /** * Get the first day of week * * @return int */ public static function getWeekStartsAt(); /** * Get weekend days * * @return array */ public static function getWeekendDays(); /** * Determines if the instance is greater (after) than another * * @example * ``` * Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:16'); // false * Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:18'); // true * Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:17'); // false * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @return bool */ public function greaterThan($date): bool; /** * Determines if the instance is greater (after) than or equal to another * * @example * ``` * Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:16'); // true * Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:18'); // true * Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:17'); // false * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @return bool */ public function greaterThanOrEqualTo($date): bool; /** * Determines if the instance is greater (after) than another * * @example * ``` * Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:16'); // false * Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:18'); // true * Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:17'); // false * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see greaterThan() * * @return bool */ public function gt($date): bool; /** * Determines if the instance is greater (after) than or equal to another * * @example * ``` * Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:16'); // true * Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:18'); // true * Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:17'); // false * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see greaterThanOrEqualTo() * * @return bool */ public function gte($date): bool; /** * Checks if the (date)time string is in a given format. * * @example * ``` * Carbon::hasFormat('11:12:45', 'h:i:s'); // true * Carbon::hasFormat('13:12:45', 'h:i:s'); // false * ``` * * @SuppressWarnings(PHPMD.EmptyCatchBlock) * * @param string $date * @param string $format * * @return bool */ public static function hasFormat($date, $format); /** * Checks if macro is registered. * * @param string $name * * @return bool */ public static function hasMacro($name); /** * Determine if a time string will produce a relative date. * * @param string $time * * @return bool true if time match a relative date, false if absolute or invalid time string */ public static function hasRelativeKeywords($time); /** * Determine if there is a valid test instance set. A valid test instance * is anything that is not null. * * @return bool true if there is a test instance, otherwise false */ public static function hasTestNow(); /** * Create a Carbon instance from a DateTime one. * * @param \DateTimeInterface $date * * @return static */ public static function instance($date); /** * Returns true if the current date matches the given string. * * @example * ``` * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019')); // true * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2018')); // false * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019-06')); // true * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('06-02')); // true * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019-06-02')); // true * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('Sunday')); // true * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('June')); // true * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23')); // true * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23:45')); // true * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23:00')); // false * var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12h')); // true * var_dump(Carbon::parse('2019-06-02 15:23:45')->is('3pm')); // true * var_dump(Carbon::parse('2019-06-02 15:23:45')->is('3am')); // false * ``` * * @param string $tester day name, month name, hour, date, etc. as string * * @return bool */ public function is(string $tester); /** * Determines if the instance is greater (after) than another * * @example * ``` * Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:16'); // false * Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:18'); // true * Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:17'); // false * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see greaterThan() * * @return bool */ public function isAfter($date): bool; /** * Determines if the instance is less (before) than another * * @example * ``` * Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:16'); // false * Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:18'); // false * Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:17'); // true * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see lessThan() * * @return bool */ public function isBefore($date): bool; /** * Determines if the instance is between two others * * @example * ``` * Carbon::parse('2018-07-25')->isBetween('2018-07-14', '2018-08-01'); // true * Carbon::parse('2018-07-25')->isBetween('2018-08-01', '2018-08-20'); // false * Carbon::parse('2018-07-25')->isBetween('2018-07-25', '2018-08-01'); // false * Carbon::parse('2018-07-25')->isBetween('2018-07-25', '2018-08-01', true); // true * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date1 * @param \Carbon\Carbon|\DateTimeInterface|mixed $date2 * @param bool $equal Indicates if an equal to comparison should be done * * @return bool */ public function isBetween($date1, $date2, $equal = true): bool; /** * Check if its the birthday. Compares the date/month values of the two dates. * * @example * ``` * Carbon::now()->subYears(5)->isBirthday(); // true * Carbon::now()->subYears(5)->subDay()->isBirthday(); // false * Carbon::parse('2019-06-05')->isBirthday(Carbon::parse('2001-06-05')); // true * Carbon::parse('2019-06-05')->isBirthday(Carbon::parse('2001-06-06')); // false * ``` * * @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use current day. * * @return bool */ public function isBirthday($date = null); /** * Determines if the instance is in the current unit given. * * @example * ``` * Carbon::now()->isCurrentUnit('hour'); // true * Carbon::now()->subHours(2)->isCurrentUnit('hour'); // false * ``` * * @param string $unit The unit to test. * * @throws \BadMethodCallException * * @return bool */ public function isCurrentUnit($unit); /** * Checks if this day is a specific day of the week. * * @example * ``` * Carbon::parse('2019-07-17')->isDayOfWeek(Carbon::WEDNESDAY); // true * Carbon::parse('2019-07-17')->isDayOfWeek(Carbon::FRIDAY); // false * Carbon::parse('2019-07-17')->isDayOfWeek('Wednesday'); // true * Carbon::parse('2019-07-17')->isDayOfWeek('Friday'); // false * ``` * * @param int $dayOfWeek * * @return bool */ public function isDayOfWeek($dayOfWeek); /** * Check if the instance is end of day. * * @example * ``` * Carbon::parse('2019-02-28 23:59:59.999999')->isEndOfDay(); // true * Carbon::parse('2019-02-28 23:59:59.123456')->isEndOfDay(); // true * Carbon::parse('2019-02-28 23:59:59')->isEndOfDay(); // true * Carbon::parse('2019-02-28 23:59:58.999999')->isEndOfDay(); // false * Carbon::parse('2019-02-28 23:59:59.999999')->isEndOfDay(true); // true * Carbon::parse('2019-02-28 23:59:59.123456')->isEndOfDay(true); // false * Carbon::parse('2019-02-28 23:59:59')->isEndOfDay(true); // false * ``` * * @param bool $checkMicroseconds check time at microseconds precision * * @return bool */ public function isEndOfDay($checkMicroseconds = false); /** * Determines if the instance is in the future, ie. greater (after) than now. * * @example * ``` * Carbon::now()->addHours(5)->isFuture(); // true * Carbon::now()->subHours(5)->isFuture(); // false * ``` * * @return bool */ public function isFuture(); /** * Returns true if the current class/instance is immutable. * * @return bool */ public static function isImmutable(); /** * Check if today is the last day of the Month * * @example * ``` * Carbon::parse('2019-02-28')->isLastOfMonth(); // true * Carbon::parse('2019-03-28')->isLastOfMonth(); // false * Carbon::parse('2019-03-30')->isLastOfMonth(); // false * Carbon::parse('2019-03-31')->isLastOfMonth(); // true * Carbon::parse('2019-04-30')->isLastOfMonth(); // true * ``` * * @return bool */ public function isLastOfMonth(); /** * Determines if the instance is a leap year. * * @example * ``` * Carbon::parse('2020-01-01')->isLeapYear(); // true * Carbon::parse('2019-01-01')->isLeapYear(); // false * ``` * * @return bool */ public function isLeapYear(); /** * Determines if the instance is a long year * * @example * ``` * Carbon::parse('2015-01-01')->isLongYear(); // true * Carbon::parse('2016-01-01')->isLongYear(); // false * ``` * * @see https://en.wikipedia.org/wiki/ISO_8601#Week_dates * * @return bool */ public function isLongYear(); /** * Check if the instance is midday. * * @example * ``` * Carbon::parse('2019-02-28 11:59:59.999999')->isMidday(); // false * Carbon::parse('2019-02-28 12:00:00')->isMidday(); // true * Carbon::parse('2019-02-28 12:00:00.999999')->isMidday(); // true * Carbon::parse('2019-02-28 12:00:01')->isMidday(); // false * ``` * * @return bool */ public function isMidday(); /** * Check if the instance is start of day / midnight. * * @example * ``` * Carbon::parse('2019-02-28 00:00:00')->isMidnight(); // true * Carbon::parse('2019-02-28 00:00:00.999999')->isMidnight(); // true * Carbon::parse('2019-02-28 00:00:01')->isMidnight(); // false * ``` * * @return bool */ public function isMidnight(); /** * Returns true if a property can be changed via setter. * * @param string $unit * * @return bool */ public static function isModifiableUnit($unit); /** * Returns true if the current class/instance is mutable. * * @return bool */ public static function isMutable(); /** * Determines if the instance is in the past, ie. less (before) than now. * * @example * ``` * Carbon::now()->subHours(5)->isPast(); // true * Carbon::now()->addHours(5)->isPast(); // false * ``` * * @return bool */ public function isPast(); /** * Compares the formatted values of the two dates. * * @example * ``` * Carbon::parse('2019-06-13')->isSameAs('Y-d', Carbon::parse('2019-12-13')); // true * Carbon::parse('2019-06-13')->isSameAs('Y-d', Carbon::parse('2019-06-14')); // false * ``` * * @param string $format date formats to compare. * @param \Carbon\Carbon|\DateTimeInterface|null $date instance to compare with or null to use current day. * * @throws \InvalidArgumentException * * @return bool */ public function isSameAs($format, $date = null); /** * Checks if the passed in date is in the same month as the instance´s month. * * @example * ``` * Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2019-01-01')); // true * Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2019-02-01')); // false * Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2018-01-01')); // false * Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2018-01-01'), false); // true * ``` * * @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use the current date. * @param bool $ofSameYear Check if it is the same month in the same year. * * @return bool */ public function isSameMonth($date = null, $ofSameYear = true); /** * Checks if the passed in date is in the same quarter as the instance quarter (and year if needed). * * @example * ``` * Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2019-03-01')); // true * Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2019-04-01')); // false * Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2018-03-01')); // false * Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2018-03-01'), false); // true * ``` * * @param \Carbon\Carbon|\DateTimeInterface|null $date The instance to compare with or null to use current day. * @param bool $ofSameYear Check if it is the same month in the same year. * * @return bool */ public function isSameQuarter($date = null, $ofSameYear = true); /** * Determines if the instance is in the current unit given. * * @example * ``` * Carbon::parse('2019-01-13')->isSameUnit('year', Carbon::parse('2019-12-25')); // true * Carbon::parse('2018-12-13')->isSameUnit('year', Carbon::parse('2019-12-25')); // false * ``` * * @param string $unit singular unit string * @param \Carbon\Carbon|\DateTimeInterface|null $date instance to compare with or null to use current day. * * @throws \InvalidArgumentException * * @return bool */ public function isSameUnit($unit, $date = null); /** * Check if the instance is start of day / midnight. * * @example * ``` * Carbon::parse('2019-02-28 00:00:00')->isStartOfDay(); // true * Carbon::parse('2019-02-28 00:00:00.999999')->isStartOfDay(); // true * Carbon::parse('2019-02-28 00:00:01')->isStartOfDay(); // false * Carbon::parse('2019-02-28 00:00:00.000000')->isStartOfDay(true); // true * Carbon::parse('2019-02-28 00:00:00.000012')->isStartOfDay(true); // false * ``` * * @param bool $checkMicroseconds check time at microseconds precision * * @return bool */ public function isStartOfDay($checkMicroseconds = false); /** * Returns true if the strict mode is globally in use, false else. * (It can be overridden in specific instances.) * * @return bool */ public static function isStrictModeEnabled(); /** * Determines if the instance is today. * * @example * ``` * Carbon::today()->isToday(); // true * Carbon::tomorrow()->isToday(); // false * ``` * * @return bool */ public function isToday(); /** * Determines if the instance is tomorrow. * * @example * ``` * Carbon::tomorrow()->isTomorrow(); // true * Carbon::yesterday()->isTomorrow(); // false * ``` * * @return bool */ public function isTomorrow(); /** * Determines if the instance is a weekday. * * @example * ``` * Carbon::parse('2019-07-14')->isWeekday(); // false * Carbon::parse('2019-07-15')->isWeekday(); // true * ``` * * @return bool */ public function isWeekday(); /** * Determines if the instance is a weekend day. * * @example * ``` * Carbon::parse('2019-07-14')->isWeekend(); // true * Carbon::parse('2019-07-15')->isWeekend(); // false * ``` * * @return bool */ public function isWeekend(); /** * Determines if the instance is yesterday. * * @example * ``` * Carbon::yesterday()->isYesterday(); // true * Carbon::tomorrow()->isYesterday(); // false * ``` * * @return bool */ public function isYesterday(); /** * Format in the current language using ISO replacement patterns. * * @param string $format * @param string|null $originalFormat provide context if a chunk has been passed alone * * @return string */ public function isoFormat(string $format, string $originalFormat = null): string; /** * Get/set the week number using given first day of week and first * day of year included in the first week. Or use ISO format if no settings * given. * * @param int|null $week * @param int|null $dayOfWeek * @param int|null $dayOfYear * * @return int|static */ public function isoWeek($week = null, $dayOfWeek = null, $dayOfYear = null); /** * Set/get the week number of year using given first day of week and first * day of year included in the first week. Or use ISO format if no settings * given. * * @param int|null $year if null, act as a getter, if not null, set the year and return current instance. * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday) * @param int|null $dayOfYear first day of year included in the week #1 * * @return int|static */ public function isoWeekYear($year = null, $dayOfWeek = null, $dayOfYear = null); /** * Get/set the ISO weekday from 1 (Monday) to 7 (Sunday). * * @param int|null $value new value for weekday if using as setter. * * @return static|int */ public function isoWeekday($value = null); /** * Get the number of weeks of the current week-year using given first day of week and first * day of year included in the first week. Or use ISO format if no settings * given. * * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday) * @param int|null $dayOfYear first day of year included in the week #1 * * @return int */ public function isoWeeksInYear($dayOfWeek = null, $dayOfYear = null); /** * Prepare the object for JSON serialization. * * @return array|string */ public function jsonSerialize(); /** * Modify to the last occurrence of a given day of the week * in the current month. If no dayOfWeek is provided, modify to the * last day of the current month. Use the supplied constants * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int|null $dayOfWeek * * @return static */ public function lastOfMonth($dayOfWeek = null); /** * Modify to the last occurrence of a given day of the week * in the current quarter. If no dayOfWeek is provided, modify to the * last day of the current quarter. Use the supplied constants * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int|null $dayOfWeek day of the week default null * * @return static */ public function lastOfQuarter($dayOfWeek = null); /** * Modify to the last occurrence of a given day of the week * in the current year. If no dayOfWeek is provided, modify to the * last day of the current year. Use the supplied constants * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int|null $dayOfWeek day of the week default null * * @return static */ public function lastOfYear($dayOfWeek = null); /** * Determines if the instance is less (before) than another * * @example * ``` * Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:16'); // false * Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:18'); // false * Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:17'); // true * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @return bool */ public function lessThan($date): bool; /** * Determines if the instance is less (before) or equal to another * * @example * ``` * Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:16'); // true * Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:18'); // false * Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:17'); // true * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @return bool */ public function lessThanOrEqualTo($date): bool; /** * Get/set the locale for the current instance. * * @param string|null $locale * @param string[] ...$fallbackLocales * * @return $this|string */ public function locale(string $locale = null, ...$fallbackLocales); /** * Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow). * Support is considered enabled if the 3 words are translated in the given locale. * * @param string $locale locale ex. en * * @return bool */ public static function localeHasDiffOneDayWords($locale); /** * Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after). * Support is considered enabled if the 4 sentences are translated in the given locale. * * @param string $locale locale ex. en * * @return bool */ public static function localeHasDiffSyntax($locale); /** * Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow). * Support is considered enabled if the 2 words are translated in the given locale. * * @param string $locale locale ex. en * * @return bool */ public static function localeHasDiffTwoDayWords($locale); /** * Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X). * Support is considered enabled if the 4 sentences are translated in the given locale. * * @param string $locale locale ex. en * * @return bool */ public static function localeHasPeriodSyntax($locale); /** * Returns true if the given locale is internally supported and has short-units support. * Support is considered enabled if either year, day or hour has a short variant translated. * * @param string $locale locale ex. en * * @return bool */ public static function localeHasShortUnits($locale); /** * Determines if the instance is less (before) than another * * @example * ``` * Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:16'); // false * Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:18'); // false * Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:17'); // true * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see lessThan() * * @return bool */ public function lt($date): bool; /** * Determines if the instance is less (before) or equal to another * * @example * ``` * Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:16'); // true * Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:18'); // false * Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:17'); // true * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see lessThanOrEqualTo() * * @return bool */ public function lte($date): bool; /** * Register a custom macro. * * @example * ``` * $userSettings = [ * 'locale' => 'pt', * 'timezone' => 'America/Sao_Paulo', * ]; * Carbon::macro('userFormat', function () use ($userSettings) { * return $this->copy()->locale($userSettings['locale'])->tz($userSettings['timezone'])->calendar(); * }); * echo Carbon::yesterday()->hours(11)->userFormat(); * ``` * * @param string $name * @param object|callable $macro * * @return void */ public static function macro($name, $macro); /** * Make a Carbon instance from given variable if possible. * * Always return a new instance. Parse only strings and only these likely to be dates (skip intervals * and recurrences). Throw an exception for invalid format, but otherwise return null. * * @param mixed $var * * @return static|null */ public static function make($var); /** * Get the maximum instance between a given instance (default now) and the current instance. * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @return static */ public function max($date = null); /** * Create a Carbon instance for the greatest supported date. * * @return static */ public static function maxValue(); /** * Get the maximum instance between a given instance (default now) and the current instance. * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see max() * * @return static */ public function maximum($date = null); /** * Return the meridiem of the current time in the current locale. * * @param bool $isLower if true, returns lowercase variant if available in the current locale. * * @return string */ public function meridiem(bool $isLower = false): string; /** * Modify to midday, default to self::$midDayAt * * @return static */ public function midDay(); /** * Get the minimum instance between a given instance (default now) and the current instance. * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @return static */ public function min($date = null); /** * Create a Carbon instance for the lowest supported date. * * @return static */ public static function minValue(); /** * Get the minimum instance between a given instance (default now) and the current instance. * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see min() * * @return static */ public function minimum($date = null); /** * Mix another object into the class. * * @example * ``` * Carbon::mixin(new class { * public function addMoon() { * return function () { * return $this->addDays(30); * }; * } * public function subMoon() { * return function () { * return $this->subDays(30); * }; * } * }); * $fullMoon = Carbon::create('2018-12-22'); * $nextFullMoon = $fullMoon->addMoon(); * $blackMoon = Carbon::create('2019-01-06'); * $previousBlackMoon = $blackMoon->subMoon(); * echo "$nextFullMoon\n"; * echo "$previousBlackMoon\n"; * ``` * * @param object|string $mixin * * @throws \ReflectionException * * @return void */ public static function mixin($mixin); /** * call \DateTime::modify if mutable or \DateTimeImmutable::modify else. * * @see https://php.net/manual/en/datetime.modify.php */ public function modify($modify); /** * Determines if the instance is not equal to another * * @example * ``` * Carbon::parse('2018-07-25 12:45:16')->ne('2018-07-25 12:45:16'); // false * Carbon::parse('2018-07-25 12:45:16')->ne(Carbon::parse('2018-07-25 12:45:16')); // false * Carbon::parse('2018-07-25 12:45:16')->ne('2018-07-25 12:45:17'); // true * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @see notEqualTo() * * @return bool */ public function ne($date): bool; /** * Modify to the next occurrence of a given modifier such as a day of * the week. If no modifier is provided, modify to the next occurrence * of the current day of the week. Use the supplied constants * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param string|int|null $modifier * * @return static */ public function next($modifier = null); /** * Go forward to the next weekday. * * @return static */ public function nextWeekday(); /** * Go forward to the next weekend day. * * @return static */ public function nextWeekendDay(); /** * Determines if the instance is not equal to another * * @example * ``` * Carbon::parse('2018-07-25 12:45:16')->notEqualTo('2018-07-25 12:45:16'); // false * Carbon::parse('2018-07-25 12:45:16')->notEqualTo(Carbon::parse('2018-07-25 12:45:16')); // false * Carbon::parse('2018-07-25 12:45:16')->notEqualTo('2018-07-25 12:45:17'); // true * ``` * * @param \Carbon\Carbon|\DateTimeInterface|mixed $date * * @return bool */ public function notEqualTo($date): bool; /** * Get a Carbon instance for the current date and time. * * @param \DateTimeZone|string|null $tz * * @return static */ public static function now($tz = null); /** * Returns a present instance in the same timezone. * * @return static */ public function nowWithSameTz(); /** * Modify to the given occurrence of a given day of the week * in the current month. If the calculated occurrence is outside the scope * of the current month, then return false and no modifications are made. * Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $nth * @param int $dayOfWeek * * @return mixed */ public function nthOfMonth($nth, $dayOfWeek); /** * Modify to the given occurrence of a given day of the week * in the current quarter. If the calculated occurrence is outside the scope * of the current quarter, then return false and no modifications are made. * Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $nth * @param int $dayOfWeek * * @return mixed */ public function nthOfQuarter($nth, $dayOfWeek); /** * Modify to the given occurrence of a given day of the week * in the current year. If the calculated occurrence is outside the scope * of the current year, then return false and no modifications are made. * Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param int $nth * @param int $dayOfWeek * * @return mixed */ public function nthOfYear($nth, $dayOfWeek); /** * Return a property with its ordinal. * * @param string $key * @param string|null $period * * @return string */ public function ordinal(string $key, string $period = null): string; /** * Create a carbon instance from a string. * * This is an alias for the constructor that allows better fluent syntax * as it allows you to do Carbon::parse('Monday next week')->fn() rather * than (new Carbon('Monday next week'))->fn(). * * @param string|null $time * @param \DateTimeZone|string|null $tz * * @return static */ public static function parse($time = null, $tz = null); /** * Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.). * * @param string $time * @param string $locale * @param \DateTimeZone|string|null $tz * * @return static */ public static function parseFromLocale($time, $locale, $tz = null); /** * Returns standardized plural of a given singular/plural unit name (in English). * * @param string $unit * * @return string */ public static function pluralUnit(string $unit): string; /** * Modify to the previous occurrence of a given modifier such as a day of * the week. If no dayOfWeek is provided, modify to the previous occurrence * of the current day of the week. Use the supplied constants * to indicate the desired dayOfWeek, ex. static::MONDAY. * * @param string|int|null $modifier * * @return static */ public function previous($modifier = null); /** * Go backward to the previous weekday. * * @return static */ public function previousWeekday(); /** * Go backward to the previous weekend day. * * @return static */ public function previousWeekendDay(); /** * Create a iterable CarbonPeriod object from current date to a given end date (and optional interval). * * @param \DateTimeInterface|Carbon|CarbonImmutable|null $end period end date * @param int|\DateInterval|string|null $interval period default interval or number of the given $unit * @param string|null $unit if specified, $interval must be an integer * * @return CarbonPeriod */ public function range($end = null, $interval = null, $unit = null); /** * Create a Carbon instance from a specific format. * * @param string $format Datetime format * @param string $time * @param \DateTimeZone|string|false|null $tz * * @throws InvalidArgumentException * * @return static|false */ public static function rawCreateFromFormat($format, $time, $tz = null); /** * @see https://php.net/manual/en/datetime.format.php * * @param string $format * * @return string */ public function rawFormat($format); /** * Create a carbon instance from a string. * * This is an alias for the constructor that allows better fluent syntax * as it allows you to do Carbon::parse('Monday next week')->fn() rather * than (new Carbon('Monday next week'))->fn(). * * @param string|null $time * @param \DateTimeZone|string|null $tz * * @return static */ public static function rawParse($time = null, $tz = null); /** * Remove all macros and generic macros. */ public static function resetMacros(); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather use the ->settings() method. * Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants * are available for quarters, years, decade, centuries, millennia (singular and plural forms). * @see settings * * Reset the month overflow behavior. * * @return void */ public static function resetMonthsOverflow(); /** * Reset the format used to the default when type juggling a Carbon instance to a string * * @return void */ public static function resetToStringFormat(); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather use the ->settings() method. * Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants * are available for quarters, years, decade, centuries, millennia (singular and plural forms). * @see settings * * Reset the month overflow behavior. * * @return void */ public static function resetYearsOverflow(); /** * Round the current instance second with given precision if specified. * * @param float|int $precision * @param string $function * * @return CarbonInterface */ public function round($precision = 1, $function = 'round'); /** * Round the current instance at the given unit with given precision if specified and the given function. * * @param string $unit * @param float|int $precision * @param string $function * * @return CarbonInterface */ public function roundUnit($unit, $precision = 1, $function = 'round'); /** * Round the current instance week. * * @param int $weekStartsAt optional start allow you to specify the day of week to use to start the week * * @return CarbonInterface */ public function roundWeek($weekStartsAt = null); /** * The number of seconds since midnight. * * @return int */ public function secondsSinceMidnight(); /** * The number of seconds until 23:59:59. * * @return int */ public function secondsUntilEndOfDay(); /** * Return a serialized string of the instance. * * @return string */ public function serialize(); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather transform Carbon object before the serialization. * * JSON serialize all Carbon instances using the given callback. * * @param callable $callback * * @return void */ public static function serializeUsing($callback); /** * Set a part of the Carbon object * * @param string|array $name * @param string|int|\DateTimeZone $value * * @throws InvalidArgumentException|ReflectionException * * @return $this */ public function set($name, $value = null); public function setDate($year, $month, $day); /** * Set the year, month, and date for this instance to that of the passed instance. * * @param \Carbon\Carbon|\DateTimeInterface $date now if null * * @return static */ public function setDateFrom($date = null); /** * Set the date and time all together. * * @param int $year * @param int $month * @param int $day * @param int $hour * @param int $minute * @param int $second * @param int $microseconds * * @return static */ public function setDateTime($year, $month, $day, $hour, $minute, $second = 0, $microseconds = 0); /** * Set the date and time for this instance to that of the passed instance. * * @param \Carbon\Carbon|\DateTimeInterface $date * * @return static */ public function setDateTimeFrom($date = null); /** * Set the fallback locale. * * @see https://symfony.com/doc/current/components/translation.html#fallback-locales * * @param string $locale */ public static function setFallbackLocale($locale); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather use the ->settings() method. * @see settings * * @param int $humanDiffOptions */ public static function setHumanDiffOptions($humanDiffOptions); /** * call \DateTime::setISODate if mutable or \DateTimeImmutable::setISODate else. * * @see https://php.net/manual/en/datetime.setisodate.php */ public function setISODate($year, $week, $day = 1); /** * Set the translator for the current instance. * * @param \Symfony\Component\Translation\TranslatorInterface $translator * * @return $this */ public function setLocalTranslator(\Symfony\Component\Translation\TranslatorInterface $translator); /** * Set the current translator locale and indicate if the source locale file exists. * Pass 'auto' as locale to use closest language from the current LC_TIME locale. * * @param string $locale locale ex. en * * @return bool */ public static function setLocale($locale); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather consider mid-day is always 12pm, then if you need to test if it's an other * hour, test it explicitly: * $date->format('G') == 13 * or to set explicitly to a given hour: * $date->setTime(13, 0, 0, 0) * * Set midday/noon hour * * @param int $hour midday hour * * @return void */ public static function setMidDayAt($hour); /** * Set a Carbon instance (real or mock) to be returned when a "now" * instance is created. The provided instance will be returned * specifically under the following conditions: * - A call to the static now() method, ex. Carbon::now() * - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null) * - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now') * - When a string containing the desired time is passed to Carbon::parse(). * * Note the timezone parameter was left out of the examples above and * has no affect as the mock value will be returned regardless of its value. * * To clear the test instance call this method using the default * parameter of null. * * /!\ Use this method for unit tests only. * * @param static|string|null $testNow real or mock Carbon instance */ public static function setTestNow($testNow = null); /** * call \DateTime::setTime if mutable or \DateTimeImmutable::setTime else. * * @see https://php.net/manual/en/datetime.settime.php */ public function setTime($hour, $minute, $second = 0, $microseconds = 0); /** * Set the hour, minute, second and microseconds for this instance to that of the passed instance. * * @param \Carbon\Carbon|\DateTimeInterface $date now if null * * @return static */ public function setTimeFrom($date = null); /** * Set the time by time string. * * @param string $time * * @return static */ public function setTimeFromTimeString($time); /** * call \DateTime::setTimestamp if mutable or \DateTimeImmutable::setTimestamp else. * * @see https://php.net/manual/en/datetime.settimestamp.php */ public function setTimestamp($unixtimestamp); /** * Set the instance's timezone from a string or object. * * @param \DateTimeZone|string $value * * @return static */ public function setTimezone($value); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather let Carbon object being casted to string with DEFAULT_TO_STRING_FORMAT, and * use other method or custom format passed to format() method if you need to dump an other string * format. * * Set the default format used when type juggling a Carbon instance to a string * * @param string|Closure|null $format * * @return void */ public static function setToStringFormat($format); /** * Set the default translator instance to use. * * @param \Symfony\Component\Translation\TranslatorInterface $translator * * @return void */ public static function setTranslator(\Symfony\Component\Translation\TranslatorInterface $translator); /** * Set specified unit to new given value. * * @param string $unit year, month, day, hour, minute, second or microsecond * @param int $value new value for given unit * * @return static */ public function setUnit($unit, $value = null); /** * Set any unit to a new value without overflowing current other unit given. * * @param string $valueUnit unit name to modify * @param int $value new value for the input unit * @param string $overflowUnit unit name to not overflow * * @return static */ public function setUnitNoOverflow($valueUnit, $value, $overflowUnit); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather use UTF-8 language packages on every machine. * * Set if UTF8 will be used for localized date/time. * * @param bool $utf8 */ public static function setUtf8($utf8); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * Use $weekStartsAt optional parameter instead when using startOfWeek, floorWeek, ceilWeek * or roundWeek method. You can also use the 'first_day_of_week' locale setting to change the * start of week according to current locale selected and implicitly the end of week. * * Set the last day of week * * @param int $day * * @return void */ public static function setWeekEndsAt($day); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * Use $weekEndsAt optional parameter instead when using endOfWeek method. You can also use the * 'first_day_of_week' locale setting to change the start of week according to current locale * selected and implicitly the end of week. * * Set the first day of week * * @param int $day week start day * * @return void */ public static function setWeekStartsAt($day); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather consider week-end is always saturday and sunday, and if you have some custom * week-end days to handle, give to those days an other name and create a macro for them: * * ``` * Carbon::macro('isDayOff', function ($date) { * return $date->isSunday() || $date->isMonday(); * }); * Carbon::macro('isNotDayOff', function ($date) { * return !$date->isDayOff(); * }); * if ($someDate->isDayOff()) ... * if ($someDate->isNotDayOff()) ... * // Add 5 not-off days * $count = 5; * while ($someDate->isDayOff() || ($count-- > 0)) { * $someDate->addDay(); * } * ``` * * Set weekend days * * @param array $days * * @return void */ public static function setWeekendDays($days); /** * Set specific options. * - strictMode: true|false|null * - monthOverflow: true|false|null * - yearOverflow: true|false|null * - humanDiffOptions: int|null * - toStringFormat: string|Closure|null * - toJsonFormat: string|Closure|null * - locale: string|null * - timezone: \DateTimeZone|string|int|null * - macros: array|null * - genericMacros: array|null * * @param array $settings * * @return $this|static */ public function settings(array $settings); /** * Set the instance's timezone from a string or object and add/subtract the offset difference. * * @param \DateTimeZone|string $value * * @return static */ public function shiftTimezone($value); /** * Get the month overflow global behavior (can be overridden in specific instances). * * @return bool */ public static function shouldOverflowMonths(); /** * Get the month overflow global behavior (can be overridden in specific instances). * * @return bool */ public static function shouldOverflowYears(); /** * @alias diffForHumans * * Get the difference in a human readable format in the current locale from current instance to an other * instance given (or now if null given). */ public function since($other = null, $syntax = null, $short = false, $parts = 1, $options = null); /** * Returns standardized singular of a given singular/plural unit name (in English). * * @param string $unit * * @return string */ public static function singularUnit(string $unit): string; /** * Modify to start of current given unit. * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16.334455') * ->startOf('month') * ->endOf('week', Carbon::FRIDAY); * ``` * * @param string $unit * @param array $params * * @return static */ public function startOf($unit, ...$params); /** * Resets the date to the first day of the century and the time to 00:00:00 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfCentury(); * ``` * * @return static */ public function startOfCentury(); /** * Resets the time to 00:00:00 start of day * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfDay(); * ``` * * @return static */ public function startOfDay(); /** * Resets the date to the first day of the decade and the time to 00:00:00 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfDecade(); * ``` * * @return static */ public function startOfDecade(); /** * Modify to start of current hour, minutes and seconds become 0 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfHour(); * ``` * * @return static */ public function startOfHour(); /** * Resets the date to the first day of the century and the time to 00:00:00 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfMillennium(); * ``` * * @return static */ public function startOfMillennium(); /** * Modify to start of current minute, seconds become 0 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfMinute(); * ``` * * @return static */ public function startOfMinute(); /** * Resets the date to the first day of the month and the time to 00:00:00 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfMonth(); * ``` * * @return static */ public function startOfMonth(); /** * Resets the date to the first day of the quarter and the time to 00:00:00 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfQuarter(); * ``` * * @return static */ public function startOfQuarter(); /** * Modify to start of current second, microseconds become 0 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16.334455') * ->startOfSecond() * ->format('H:i:s.u'); * ``` * * @return static */ public function startOfSecond(); /** * Resets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfWeek() . "\n"; * echo Carbon::parse('2018-07-25 12:45:16')->locale('ar')->startOfWeek() . "\n"; * echo Carbon::parse('2018-07-25 12:45:16')->startOfWeek(Carbon::SUNDAY) . "\n"; * ``` * * @param int $weekStartsAt optional start allow you to specify the day of week to use to start the week * * @return static */ public function startOfWeek($weekStartsAt = null); /** * Resets the date to the first day of the year and the time to 00:00:00 * * @example * ``` * echo Carbon::parse('2018-07-25 12:45:16')->startOfYear(); * ``` * * @return static */ public function startOfYear(); /** * Subtract given units or interval to the current instance. * * @example $date->sub('hour', 3) * @example $date->sub(15, 'days') * @example $date->sub(CarbonInterval::days(4)) * * @param string|DateInterval $unit * @param int $value * @param bool|null $overflow * * @return CarbonInterface */ public function sub($unit, $value = 1, $overflow = null); public function subRealUnit($unit, $value = 1); /** * Subtract given units to the current instance. * * @param string $unit * @param int $value * @param bool|null $overflow * * @return CarbonInterface */ public function subUnit($unit, $value = 1, $overflow = null); /** * Subtract any unit to a new value without overflowing current other unit given. * * @param string $valueUnit unit name to modify * @param int $value amount to subtract to the input unit * @param string $overflowUnit unit name to not overflow * * @return static */ public function subUnitNoOverflow($valueUnit, $value, $overflowUnit); /** * Subtract given units or interval to the current instance. * * @see sub() * * @param string|DateInterval $unit * @param int $value * @param bool|null $overflow * * @return CarbonInterface */ public function subtract($unit, $value = 1, $overflow = null); /** * Get the difference in a human readable format in the current locale from current instance to an other * instance given (or now if null given). * * @return string */ public function timespan($other = null, $timezone = null); /** * Set the instance's timestamp. * * @param int $value * * @return static */ public function timestamp($value); /** * @alias setTimezone * * @param \DateTimeZone|string $value * * @return static */ public function timezone($value); /** * Get the difference in a human readable format in the current locale from an other * instance given (or now if null given) to current instance. * * When comparing a value in the past to default now: * 1 hour from now * 5 months from now * * When comparing a value in the future to default now: * 1 hour ago * 5 months ago * * When comparing a value in the past to another value: * 1 hour after * 5 months after * * When comparing a value in the future to another value: * 1 hour before * 5 months before * * @param Carbon|\DateTimeInterface|string|array|null $other if array passed, will be used as parameters array, see $syntax below; * if null passed, now will be used as comparison reference; * if any other type, it will be converted to date and used as reference. * @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains: * - 'syntax' entry (see below) * - 'short' entry (see below) * - 'parts' entry (see below) * - 'options' entry (see below) * - 'join' entry determines how to join multiple parts of the string * ` - if $join is a string, it's used as a joiner glue * ` - if $join is a callable/closure, it get the list of string and should return a string * ` - if $join is an array, the first item will be the default glue, and the second item * ` will be used instead of the glue for the last item * ` - if $join is true, it will be guessed from the locale ('list' translation file entry) * ` - if $join is missing, a space will be used as glue * - 'other' entry (see above) * if int passed, it add modifiers: * Possible values: * - CarbonInterface::DIFF_ABSOLUTE no modifiers * - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier * - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier * Default value: CarbonInterface::DIFF_ABSOLUTE * @param bool $short displays short format of time units * @param int $parts maximum number of parts to display (default value: 1: single unit) * @param int $options human diff options * * @return string */ public function to($other = null, $syntax = null, $short = false, $parts = 1, $options = null); /** * Get default array representation. * * @example * ``` * var_dump(Carbon::now()->toArray()); * ``` * * @return array */ public function toArray(); /** * Format the instance as ATOM * * @example * ``` * echo Carbon::now()->toAtomString(); * ``` * * @return string */ public function toAtomString(); /** * Format the instance as COOKIE * * @example * ``` * echo Carbon::now()->toCookieString(); * ``` * * @return string */ public function toCookieString(); /** * @alias toDateTime * * Return native DateTime PHP object matching the current instance. * * @example * ``` * var_dump(Carbon::now()->toDate()); * ``` * * @return DateTime */ public function toDate(); /** * Format the instance as date * * @example * ``` * echo Carbon::now()->toDateString(); * ``` * * @return string */ public function toDateString(); /** * Return native DateTime PHP object matching the current instance. * * @example * ``` * var_dump(Carbon::now()->toDateTime()); * ``` * * @return DateTime */ public function toDateTime(); /** * Format the instance as date and time T-separated with no timezone * * @example * ``` * echo Carbon::now()->toDateTimeLocalString(); * ``` * * @return string */ public function toDateTimeLocalString(); /** * Format the instance as date and time * * @example * ``` * echo Carbon::now()->toDateTimeString(); * ``` * * @return string */ public function toDateTimeString(); /** * Format the instance with day, date and time * * @example * ``` * echo Carbon::now()->toDayDateTimeString(); * ``` * * @return string */ public function toDayDateTimeString(); /** * Format the instance as a readable date * * @example * ``` * echo Carbon::now()->toFormattedDateString(); * ``` * * @return string */ public function toFormattedDateString(); /** * Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z, if $keepOffset truthy, offset will be kept: * 1977-04-22T01:00:00-05:00). * * @example * ``` * echo Carbon::now('America/Toronto')->toISOString() . "\n"; * echo Carbon::now('America/Toronto')->toISOString(true) . "\n"; * ``` * * @param bool $keepOffset Pass true to keep the date offset. Else forced to UTC. * * @return null|string */ public function toISOString($keepOffset = false); /** * Return a immutable copy of the instance. * * @return CarbonImmutable */ public function toImmutable(); /** * Format the instance as ISO8601 * * @example * ``` * echo Carbon::now()->toIso8601String(); * ``` * * @return string */ public function toIso8601String(); /** * Convert the instance to UTC and return as Zulu ISO8601 * * @example * ``` * echo Carbon::now()->toIso8601ZuluString(); * ``` * * @return string */ public function toIso8601ZuluString(); /** * Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z) with UTC timezone. * * @example * ``` * echo Carbon::now('America/Toronto')->toJSON(); * ``` * * @return null|string */ public function toJSON(); /** * Return a mutable copy of the instance. * * @return Carbon */ public function toMutable(); /** * Get the difference in a human readable format in the current locale from an other * instance given to now * * @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains: * - 'syntax' entry (see below) * - 'short' entry (see below) * - 'parts' entry (see below) * - 'options' entry (see below) * - 'join' entry determines how to join multiple parts of the string * ` - if $join is a string, it's used as a joiner glue * ` - if $join is a callable/closure, it get the list of string and should return a string * ` - if $join is an array, the first item will be the default glue, and the second item * ` will be used instead of the glue for the last item * ` - if $join is true, it will be guessed from the locale ('list' translation file entry) * ` - if $join is missing, a space will be used as glue * if int passed, it add modifiers: * Possible values: * - CarbonInterface::DIFF_ABSOLUTE no modifiers * - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier * - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier * Default value: CarbonInterface::DIFF_ABSOLUTE * @param bool $short displays short format of time units * @param int $parts maximum number of parts to display (default value: 1: single part) * @param int $options human diff options * * @return string */ public function toNow($syntax = null, $short = false, $parts = 1, $options = null); /** * Get default object representation. * * @example * ``` * var_dump(Carbon::now()->toObject()); * ``` * * @return object */ public function toObject(); /** * Create a iterable CarbonPeriod object from current date to a given end date (and optional interval). * * @param \DateTimeInterface|Carbon|CarbonImmutable|null $end period end date * @param int|\DateInterval|string|null $interval period default interval or number of the given $unit * @param string|null $unit if specified, $interval must be an integer * * @return CarbonPeriod */ public function toPeriod($end = null, $interval = null, $unit = null); /** * Format the instance as RFC1036 * * @example * ``` * echo Carbon::now()->toRfc1036String(); * ``` * * @return string */ public function toRfc1036String(); /** * Format the instance as RFC1123 * * @example * ``` * echo Carbon::now()->toRfc1123String(); * ``` * * @return string */ public function toRfc1123String(); /** * Format the instance as RFC2822 * * @example * ``` * echo Carbon::now()->toRfc2822String(); * ``` * * @return string */ public function toRfc2822String(); /** * Format the instance as RFC3339 * * @example * ``` * echo Carbon::now()->toRfc3339String(); * ``` * * @return string */ public function toRfc3339String(); /** * Format the instance as RFC7231 * * @example * ``` * echo Carbon::now()->toRfc7231String(); * ``` * * @return string */ public function toRfc7231String(); /** * Format the instance as RFC822 * * @example * ``` * echo Carbon::now()->toRfc822String(); * ``` * * @return string */ public function toRfc822String(); /** * Format the instance as RFC850 * * @example * ``` * echo Carbon::now()->toRfc850String(); * ``` * * @return string */ public function toRfc850String(); /** * Format the instance as RSS * * @example * ``` * echo Carbon::now()->toRssString(); * ``` * * @return string */ public function toRssString(); /** * Returns english human readable complete date string. * * @example * ``` * echo Carbon::now()->toString(); * ``` * * @return string */ public function toString(); /** * Format the instance as time * * @example * ``` * echo Carbon::now()->toTimeString(); * ``` * * @return string */ public function toTimeString(); /** * Format the instance as W3C * * @example * ``` * echo Carbon::now()->toW3cString(); * ``` * * @return string */ public function toW3cString(); /** * Create a Carbon instance for today. * * @param \DateTimeZone|string|null $tz * * @return static */ public static function today($tz = null); /** * Create a Carbon instance for tomorrow. * * @param \DateTimeZone|string|null $tz * * @return static */ public static function tomorrow($tz = null); /** * Translate using translation string or callback available. * * @param string $key * @param array $parameters * @param null $number * @param \Symfony\Component\Translation\TranslatorInterface $translator * * @return string */ public function translate(string $key, array $parameters = [], $number = null, \Symfony\Component\Translation\TranslatorInterface $translator = null): string; /** * Translate a time string from a locale to an other. * * @param string $timeString time string to translate * @param string|null $from input locale of the $timeString parameter (`Carbon::getLocale()` by default) * @param string|null $to output locale of the result returned (`"en"` by default) * @param int $mode specify what to translate with options: * - CarbonInterface::TRANSLATE_ALL (default) * - CarbonInterface::TRANSLATE_MONTHS * - CarbonInterface::TRANSLATE_DAYS * - CarbonInterface::TRANSLATE_UNITS * - CarbonInterface::TRANSLATE_MERIDIEM * You can use pipe to group: CarbonInterface::TRANSLATE_MONTHS | CarbonInterface::TRANSLATE_DAYS * * @return string */ public static function translateTimeString($timeString, $from = null, $to = null, $mode = 15); /** * Translate a time string from the current locale (`$date->locale()`) to an other. * * @param string $timeString time string to translate * @param string|null $to output locale of the result returned ("en" by default) * * @return string */ public function translateTimeStringTo($timeString, $to = null); /** * Translate using translation string or callback available. * * @param \Symfony\Component\Translation\TranslatorInterface $translator * @param string $key * @param array $parameters * @param null $number * * @return string */ public static function translateWith(\Symfony\Component\Translation\TranslatorInterface $translator, string $key, array $parameters = [], $number = null): string; /** * Format as ->format() do (using date replacements patterns from http://php.net/manual/fr/function.date.php) * but translate words whenever possible (months, day names, etc.) using the current locale. * * @param string $format * * @return string */ public function translatedFormat(string $format): string; /** * Set the timezone or returns the timezone name if no arguments passed. * * @param \DateTimeZone|string $value * * @return static|string */ public function tz($value = null); /** * @alias getTimestamp * * Returns the UNIX timestamp for the current date. * * @return int */ public function unix(); /** * @alias to * * Get the difference in a human readable format in the current locale from an other * instance given (or now if null given) to current instance. * * @param Carbon|\DateTimeInterface|string|array|null $other if array passed, will be used as parameters array, see $syntax below; * if null passed, now will be used as comparison reference; * if any other type, it will be converted to date and used as reference. * @param int|array $syntax if array passed, parameters will be extracted from it, the array may contains: * - 'syntax' entry (see below) * - 'short' entry (see below) * - 'parts' entry (see below) * - 'options' entry (see below) * - 'join' entry determines how to join multiple parts of the string * ` - if $join is a string, it's used as a joiner glue * ` - if $join is a callable/closure, it get the list of string and should return a string * ` - if $join is an array, the first item will be the default glue, and the second item * ` will be used instead of the glue for the last item * ` - if $join is true, it will be guessed from the locale ('list' translation file entry) * ` - if $join is missing, a space will be used as glue * - 'other' entry (see above) * if int passed, it add modifiers: * Possible values: * - CarbonInterface::DIFF_ABSOLUTE no modifiers * - CarbonInterface::DIFF_RELATIVE_TO_NOW add ago/from now modifier * - CarbonInterface::DIFF_RELATIVE_TO_OTHER add before/after modifier * Default value: CarbonInterface::DIFF_ABSOLUTE * @param bool $short displays short format of time units * @param int $parts maximum number of parts to display (default value: 1: single unit) * @param int $options human diff options * * @return string */ public function until($other = null, $syntax = null, $short = false, $parts = 1, $options = null); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather use the ->settings() method. * Or you can use method variants: addMonthsWithOverflow/addMonthsNoOverflow, same variants * are available for quarters, years, decade, centuries, millennia (singular and plural forms). * @see settings * * Indicates if months should be calculated with overflow. * * @param bool $monthsOverflow * * @return void */ public static function useMonthsOverflow($monthsOverflow = true); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather use the ->settings() method. * @see settings * * Enable the strict mode (or disable with passing false). * * @param bool $strictModeEnabled */ public static function useStrictMode($strictModeEnabled = true); /** * @deprecated To avoid conflict between different third-party libraries, static setters should not be used. * You should rather use the ->settings() method. * Or you can use method variants: addYearsWithOverflow/addYearsNoOverflow, same variants * are available for quarters, years, decade, centuries, millennia (singular and plural forms). * @see settings * * Indicates if years should be calculated with overflow. * * @param bool $yearsOverflow * * @return void */ public static function useYearsOverflow($yearsOverflow = true); /** * Set the instance's timezone to UTC. * * @return static */ public function utc(); /** * Returns the minutes offset to UTC if no arguments passed, else set the timezone with given minutes shift passed. * * @param int|null $offset * * @return int|static */ public function utcOffset(int $offset = null); /** * Returns the milliseconds timestamps used amongst other by Date javascript objects. * * @return float */ public function valueOf(); /** * Get/set the week number using given first day of week and first * day of year included in the first week. Or use US format if no settings * given (Sunday / Jan 6). * * @param int|null $week * @param int|null $dayOfWeek * @param int|null $dayOfYear * * @return int|static */ public function week($week = null, $dayOfWeek = null, $dayOfYear = null); /** * Set/get the week number of year using given first day of week and first * day of year included in the first week. Or use US format if no settings * given (Sunday / Jan 6). * * @param int|null $year if null, act as a getter, if not null, set the year and return current instance. * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday) * @param int|null $dayOfYear first day of year included in the week #1 * * @return int|static */ public function weekYear($year = null, $dayOfWeek = null, $dayOfYear = null); /** * Get/set the weekday from 0 (Sunday) to 6 (Saturday). * * @param int|null $value new value for weekday if using as setter. * * @return static|int */ public function weekday($value = null); /** * Get the number of weeks of the current week-year using given first day of week and first * day of year included in the first week. Or use US format if no settings * given (Sunday / Jan 6). * * @param int|null $dayOfWeek first date of week from 0 (Sunday) to 6 (Saturday) * @param int|null $dayOfYear first day of year included in the week #1 * * @return int */ public function weeksInYear($dayOfWeek = null, $dayOfYear = null); /** * Create a Carbon instance for yesterday. * * @param \DateTimeZone|string|null $tz * * @return static */ public static function yesterday($tz = null); // }