class DateFactory

Constants

DEFAULT_CLASS_NAME

The default class that will be used for all created dates.

Properties

static protected null|CarbonInterface> $dateClass

The type (class) of dates that should be created.

static protected Closure|null $callable

This callable may be used to intercept date creation.

static protected Factory|null $factory

The Carbon factory that should be used when creating dates.

Methods

static void
use(mixed $handler)

Use the given handler when generating dates (class name, callable, or factory).

static void
useDefault()

Use the default date class when generating dates.

static void
useCallable(callable $callable)

Execute the given callable on each date creation.

static void
useClass(string $dateClass)

Use the given date type (class) when generating dates.

static void
useFactory(Factory $factory)

Use the given Carbon factory when generating dates.

static void
flushState()

Flush all static state.

mixed
__call(string $method, array $parameters)

Handle dynamic calls to generate dates.

bool
canBeCreatedFromFormat(?string $date, string $format)

No description

CarbonInterface
create(mixed $year = '0', mixed $month = '1', mixed $day = '1', mixed $hour = '0', mixed $minute = '0', mixed $second = '0', mixed $timezone = 'null')

No description

CarbonInterface
createFromDate(mixed $year = 'null', mixed $month = 'null', mixed $day = 'null', mixed $timezone = 'null')

No description

CarbonInterface
createFromFormat(mixed $format, mixed $time, mixed $timezone = 'null')

No description

CarbonInterface
createFromIsoFormat(string $format, string $time, mixed $timezone = 'null', ?string $locale = '\'en\'', TranslatorInterface $translator = 'null')

No description

CarbonInterface
createFromLocaleFormat(string $format, string $locale, string $time, mixed $timezone = 'null')

No description

CarbonInterface
createFromLocaleIsoFormat(string $format, string $locale, string $time, mixed $timezone = 'null')

No description

CarbonInterface
createFromTime(mixed $hour = '0', mixed $minute = '0', mixed $second = '0', mixed $timezone = 'null')

No description

CarbonInterface
createFromTimeString(string $time, DateTimeZone|string|int|null $timezone = 'null')

No description

CarbonInterface
createFromTimestamp(string|int|float $timestamp, DateTimeZone|string|int|null $timezone = 'null')

No description

CarbonInterface
createFromTimestampMs(string|int|float $timestamp, DateTimeZone|string|int|null $timezone = 'null')

No description

CarbonInterface
createFromTimestampMsUTC(mixed $timestamp)

No description

CarbonInterface
createFromTimestampUTC(float|int|string $timestamp)

No description

CarbonInterface
createMidnightDate(mixed $year = 'null', mixed $month = 'null', mixed $day = 'null', mixed $timezone = 'null')

No description

CarbonInterface
createSafe(mixed $year = 'null', mixed $month = 'null', mixed $day = 'null', mixed $hour = 'null', mixed $minute = 'null', mixed $second = 'null', mixed $timezone = 'null')

No description

CarbonInterface
createStrict(?int $year = '0', ?int $month = '1', ?int $day = '1', ?int $hour = '0', ?int $minute = '0', ?int $second = '0', mixed $timezone = 'null')

No description

void
disableHumanDiffOption(mixed $humanDiffOption)

No description

void
enableHumanDiffOption(mixed $humanDiffOption)

No description

mixed
executeWithLocale(string $locale, callable $func)

No description

CarbonInterface
fromSerialized(mixed $value)

No description

array
getAvailableLocales()

No description

array
getAvailableLocalesInfo()

No description

array
getDays()

No description

null|string
getFallbackLocale()

No description

array
getFormatsToIsoReplacements()

No description

int
getHumanDiffOptions()

No description

array
getIsoUnits()

No description

array|false
getLastErrors()

No description

string
getLocale()

No description

int
getMidDayAt()

No description

string
getTimeFormatByPrecision(string $unitPrecision)

No description

Closure|string
getTranslationMessageWith(mixed $translator, string $key, ?string $locale = 'null', ?string $default = 'null')

No description

CarbonInterface
getTestNow()

No description

TranslatorInterface
getTranslator()

No description

int
getWeekEndsAt(?string $locale = 'null')

No description

int
getWeekStartsAt(?string $locale = 'null')

No description

array
getWeekendDays()

No description

bool
hasFormat(string $date, string $format)

No description

bool
hasFormatWithModifiers(string $date, string $format)

No description

bool
hasMacro(mixed $name)

No description

bool
hasRelativeKeywords(?string $time)

No description

bool
hasTestNow()

No description

CarbonInterface
instance(DateTimeInterface $date)

No description

bool
isImmutable()

No description

bool
isModifiableUnit(mixed $unit)

No description

bool
isMutable()

No description

bool
isStrictModeEnabled()

No description

bool
localeHasDiffOneDayWords(string $locale)

No description

bool
localeHasDiffSyntax(string $locale)

No description

bool
localeHasDiffTwoDayWords(string $locale)

No description

bool
localeHasPeriodSyntax(mixed $locale)

No description

bool
localeHasShortUnits(string $locale)

No description

void
macro(string $name, ?callable $macro)

No description

CarbonInterface
make(mixed $var, DateTimeZone|string|null $timezone = 'null')

No description

void
mixin(object|string $mixin)

No description

CarbonInterface
now(DateTimeZone|string|int|null $timezone = 'null')

No description

CarbonInterface
parse(Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = 'null')

No description

CarbonInterface
parseFromLocale(string $time, ?string $locale = 'null', DateTimeZone|string|int|null $timezone = 'null')

No description

string
pluralUnit(string $unit)

No description

CarbonInterface
rawCreateFromFormat(string $format, string $time, mixed $timezone = 'null')

No description

CarbonInterface
rawParse(Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = 'null')

No description

void
resetMonthsOverflow()

No description

void
resetToStringFormat()

No description

void
resetYearsOverflow()

No description

void
serializeUsing(mixed $callback)

No description

void
setHumanDiffOptions(mixed $humanDiffOptions)

No description

void
setFallbackLocale(string $locale)

No description

void
setLocale(string $locale)

No description

void
setMidDayAt(mixed $hour)

No description

void
setTestNow(mixed $testNow = 'null')

No description

void
setTestNowAndTimezone(mixed $testNow = 'null', mixed $timezone = 'null')

No description

void
setToStringFormat(Closure|string $format)

No description

void
setTranslator(TranslatorInterface $translator)

No description

void
setWeekendDays(mixed $days)

No description

bool
shouldOverflowMonths()

No description

bool
shouldOverflowYears()

No description

string
singularUnit(string $unit)

No description

void
sleep(float|int $seconds)

No description

CarbonInterface
today(DateTimeZone|string|int|null $timezone = 'null')

No description

CarbonInterface
tomorrow(DateTimeZone|string|int|null $timezone = 'null')

No description

string
translateTimeString(string $timeString, ?string $from = 'null', ?string $to = 'null', int $mode = '\\Carbon\\CarbonInterface::TRANSLATE_ALL')

No description

string
translateWith(TranslatorInterface $translator, string $key, array $parameters = '[]', mixed $number = 'null')

No description

void
useMonthsOverflow(mixed $monthsOverflow = 'true')

No description

void
useStrictMode(mixed $strictModeEnabled = 'true')

No description

void
useYearsOverflow(mixed $yearsOverflow = 'true')

No description

mixed
withTestNow(mixed $testNow, callable $callback)

No description

Factory
withTimeZone(DateTimeZone|int|string $timezone)

No description

CarbonInterface
yesterday(DateTimeZone|string|int|null $timezone = 'null')

No description

Details

at line 140
static void use(mixed $handler)

Use the given handler when generating dates (class name, callable, or factory).

Boot-only. The selected handler persists in static state for the worker lifetime and affects date creation in every subsequent request.

Parameters

mixed $handler

Return Value

void

Exceptions

InvalidArgumentException

at line 168
static void useDefault()

Use the default date class when generating dates.

Boot-only. Clearing the worker-wide handler affects date creation in every subsequent request.

Return Value

void

at line 181
static void useCallable(callable $callable)

Execute the given callable on each date creation.

Boot-only. The callable persists in a static property for the worker lifetime and runs on every date creation across all coroutines.

Parameters

callable $callable

Return Value

void

at line 197
static void useClass(string $dateClass)

Use the given date type (class) when generating dates.

Boot-only. The class name persists in a static property for the worker lifetime and is used for every date creation across all coroutines.

Parameters

string $dateClass

Return Value

void

at line 220
static void useFactory(Factory $factory)

Use the given Carbon factory when generating dates.

Boot-only. The factory persists in a static property for the worker lifetime and is used for every date creation across all coroutines.

Parameters

Factory $factory

Return Value

void

at line 231
static void flushState()

Flush all static state.

Return Value

void

at line 239
mixed __call(string $method, array $parameters)

Handle dynamic calls to generate dates.

Parameters

string $method
array $parameters

Return Value

mixed

at line 106
bool canBeCreatedFromFormat(?string $date, string $format)

No description

Parameters

?string $date
string $format

Return Value

bool

at line 106
CarbonInterface create(mixed $year = '0', mixed $month = '1', mixed $day = '1', mixed $hour = '0', mixed $minute = '0', mixed $second = '0', mixed $timezone = 'null')

No description

Parameters

mixed $year
mixed $month
mixed $day
mixed $hour
mixed $minute
mixed $second
mixed $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface createFromDate(mixed $year = 'null', mixed $month = 'null', mixed $day = 'null', mixed $timezone = 'null')

No description

Parameters

mixed $year
mixed $month
mixed $day
mixed $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface createFromFormat(mixed $format, mixed $time, mixed $timezone = 'null')

No description

Parameters

mixed $format
mixed $time
mixed $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface createFromIsoFormat(string $format, string $time, mixed $timezone = 'null', ?string $locale = '\'en\'', TranslatorInterface $translator = 'null')

No description

Parameters

string $format
string $time
mixed $timezone
?string $locale
TranslatorInterface $translator

Return Value

CarbonInterface

at line 106
CarbonInterface createFromLocaleFormat(string $format, string $locale, string $time, mixed $timezone = 'null')

No description

Parameters

string $format
string $locale
string $time
mixed $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface createFromLocaleIsoFormat(string $format, string $locale, string $time, mixed $timezone = 'null')

No description

Parameters

string $format
string $locale
string $time
mixed $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface createFromTime(mixed $hour = '0', mixed $minute = '0', mixed $second = '0', mixed $timezone = 'null')

No description

Parameters

mixed $hour
mixed $minute
mixed $second
mixed $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface createFromTimeString(string $time, DateTimeZone|string|int|null $timezone = 'null')

No description

Parameters

string $time
DateTimeZone|string|int|null $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface createFromTimestamp(string|int|float $timestamp, DateTimeZone|string|int|null $timezone = 'null')

No description

Parameters

string|int|float $timestamp
DateTimeZone|string|int|null $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface createFromTimestampMs(string|int|float $timestamp, DateTimeZone|string|int|null $timezone = 'null')

No description

Parameters

string|int|float $timestamp
DateTimeZone|string|int|null $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface createFromTimestampMsUTC(mixed $timestamp)

No description

Parameters

mixed $timestamp

Return Value

CarbonInterface

at line 106
CarbonInterface createFromTimestampUTC(float|int|string $timestamp)

No description

Parameters

float|int|string $timestamp

Return Value

CarbonInterface

at line 106
CarbonInterface createMidnightDate(mixed $year = 'null', mixed $month = 'null', mixed $day = 'null', mixed $timezone = 'null')

No description

Parameters

mixed $year
mixed $month
mixed $day
mixed $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface createSafe(mixed $year = 'null', mixed $month = 'null', mixed $day = 'null', mixed $hour = 'null', mixed $minute = 'null', mixed $second = 'null', mixed $timezone = 'null')

No description

Parameters

mixed $year
mixed $month
mixed $day
mixed $hour
mixed $minute
mixed $second
mixed $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface createStrict(?int $year = '0', ?int $month = '1', ?int $day = '1', ?int $hour = '0', ?int $minute = '0', ?int $second = '0', mixed $timezone = 'null')

No description

Parameters

?int $year
?int $month
?int $day
?int $hour
?int $minute
?int $second
mixed $timezone

Return Value

CarbonInterface

at line 106
void disableHumanDiffOption(mixed $humanDiffOption)

No description

Parameters

mixed $humanDiffOption

Return Value

void

at line 106
void enableHumanDiffOption(mixed $humanDiffOption)

No description

Parameters

mixed $humanDiffOption

Return Value

void

at line 106
mixed executeWithLocale(string $locale, callable $func)

No description

Parameters

string $locale
callable $func

Return Value

mixed

at line 106
CarbonInterface fromSerialized(mixed $value)

No description

Parameters

mixed $value

Return Value

CarbonInterface

at line 106
array getAvailableLocales()

No description

Return Value

array

at line 106
array getAvailableLocalesInfo()

No description

Return Value

array

at line 106
array getDays()

No description

Return Value

array

at line 106
null|string getFallbackLocale()

No description

Return Value

null|string

at line 106
array getFormatsToIsoReplacements()

No description

Return Value

array

at line 106
int getHumanDiffOptions()

No description

Return Value

int

at line 106
array getIsoUnits()

No description

Return Value

array

at line 106
array|false getLastErrors()

No description

Return Value

array|false

at line 106
string getLocale()

No description

Return Value

string

at line 106
int getMidDayAt()

No description

Return Value

int

at line 106
string getTimeFormatByPrecision(string $unitPrecision)

No description

Parameters

string $unitPrecision

Return Value

string

at line 106
Closure|string getTranslationMessageWith(mixed $translator, string $key, ?string $locale = 'null', ?string $default = 'null')

No description

Parameters

mixed $translator
string $key
?string $locale
?string $default

Return Value

Closure|string

at line 106
CarbonInterface getTestNow()

No description

Return Value

CarbonInterface

at line 106
TranslatorInterface getTranslator()

No description

Return Value

TranslatorInterface

at line 106
int getWeekEndsAt(?string $locale = 'null')

No description

Parameters

?string $locale

Return Value

int

at line 106
int getWeekStartsAt(?string $locale = 'null')

No description

Parameters

?string $locale

Return Value

int

at line 106
array getWeekendDays()

No description

Return Value

array

at line 106
bool hasFormat(string $date, string $format)

No description

Parameters

string $date
string $format

Return Value

bool

at line 106
bool hasFormatWithModifiers(string $date, string $format)

No description

Parameters

string $date
string $format

Return Value

bool

at line 106
bool hasMacro(mixed $name)

No description

Parameters

mixed $name

Return Value

bool

at line 106
bool hasRelativeKeywords(?string $time)

No description

Parameters

?string $time

Return Value

bool

at line 106
bool hasTestNow()

No description

Return Value

bool

at line 106
CarbonInterface instance(DateTimeInterface $date)

No description

Parameters

DateTimeInterface $date

Return Value

CarbonInterface

at line 106
bool isImmutable()

No description

Return Value

bool

at line 106
bool isModifiableUnit(mixed $unit)

No description

Parameters

mixed $unit

Return Value

bool

at line 106
bool isMutable()

No description

Return Value

bool

at line 106
bool isStrictModeEnabled()

No description

Return Value

bool

at line 106
bool localeHasDiffOneDayWords(string $locale)

No description

Parameters

string $locale

Return Value

bool

at line 106
bool localeHasDiffSyntax(string $locale)

No description

Parameters

string $locale

Return Value

bool

at line 106
bool localeHasDiffTwoDayWords(string $locale)

No description

Parameters

string $locale

Return Value

bool

at line 106
bool localeHasPeriodSyntax(mixed $locale)

No description

Parameters

mixed $locale

Return Value

bool

at line 106
bool localeHasShortUnits(string $locale)

No description

Parameters

string $locale

Return Value

bool

at line 106
void macro(string $name, ?callable $macro)

No description

Parameters

string $name
?callable $macro

Return Value

void

at line 106
CarbonInterface make(mixed $var, DateTimeZone|string|null $timezone = 'null')

No description

Parameters

mixed $var
DateTimeZone|string|null $timezone

Return Value

CarbonInterface

at line 106
void mixin(object|string $mixin)

No description

Parameters

object|string $mixin

Return Value

void

at line 106
CarbonInterface now(DateTimeZone|string|int|null $timezone = 'null')

No description

Parameters

DateTimeZone|string|int|null $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface parse(Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = 'null')

No description

Parameters

Month|string|int|float|null $time
DateTimeZone|string|int|null $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface parseFromLocale(string $time, ?string $locale = 'null', DateTimeZone|string|int|null $timezone = 'null')

No description

Parameters

string $time
?string $locale
DateTimeZone|string|int|null $timezone

Return Value

CarbonInterface

at line 106
string pluralUnit(string $unit)

No description

Parameters

string $unit

Return Value

string

at line 106
CarbonInterface rawCreateFromFormat(string $format, string $time, mixed $timezone = 'null')

No description

Parameters

string $format
string $time
mixed $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface rawParse(Month|string|int|float|null $time, DateTimeZone|string|int|null $timezone = 'null')

No description

Parameters

Month|string|int|float|null $time
DateTimeZone|string|int|null $timezone

Return Value

CarbonInterface

at line 106
void resetMonthsOverflow()

No description

Return Value

void

at line 106
void resetToStringFormat()

No description

Return Value

void

at line 106
void resetYearsOverflow()

No description

Return Value

void

at line 106
void serializeUsing(mixed $callback)

No description

Parameters

mixed $callback

Return Value

void

at line 106
void setHumanDiffOptions(mixed $humanDiffOptions)

No description

Parameters

mixed $humanDiffOptions

Return Value

void

at line 106
void setFallbackLocale(string $locale)

No description

Parameters

string $locale

Return Value

void

at line 106
void setLocale(string $locale)

No description

Parameters

string $locale

Return Value

void

at line 106
void setMidDayAt(mixed $hour)

No description

Parameters

mixed $hour

Return Value

void

at line 106
void setTestNow(mixed $testNow = 'null')

No description

Parameters

mixed $testNow

Return Value

void

at line 106
void setTestNowAndTimezone(mixed $testNow = 'null', mixed $timezone = 'null')

No description

Parameters

mixed $testNow
mixed $timezone

Return Value

void

at line 106
void setToStringFormat(Closure|string $format)

No description

Parameters

Closure|string $format

Return Value

void

at line 106
void setTranslator(TranslatorInterface $translator)

No description

Parameters

TranslatorInterface $translator

Return Value

void

at line 106
void setWeekendDays(mixed $days)

No description

Parameters

mixed $days

Return Value

void

at line 106
bool shouldOverflowMonths()

No description

Return Value

bool

at line 106
bool shouldOverflowYears()

No description

Return Value

bool

at line 106
string singularUnit(string $unit)

No description

Parameters

string $unit

Return Value

string

at line 106
void sleep(float|int $seconds)

No description

Parameters

float|int $seconds

Return Value

void

at line 106
CarbonInterface today(DateTimeZone|string|int|null $timezone = 'null')

No description

Parameters

DateTimeZone|string|int|null $timezone

Return Value

CarbonInterface

at line 106
CarbonInterface tomorrow(DateTimeZone|string|int|null $timezone = 'null')

No description

Parameters

DateTimeZone|string|int|null $timezone

Return Value

CarbonInterface

at line 106
string translateTimeString(string $timeString, ?string $from = 'null', ?string $to = 'null', int $mode = '\\Carbon\\CarbonInterface::TRANSLATE_ALL')

No description

Parameters

string $timeString
?string $from
?string $to
int $mode

Return Value

string

at line 106
string translateWith(TranslatorInterface $translator, string $key, array $parameters = '[]', mixed $number = 'null')

No description

Parameters

TranslatorInterface $translator
string $key
array $parameters
mixed $number

Return Value

string

at line 106
void useMonthsOverflow(mixed $monthsOverflow = 'true')

No description

Parameters

mixed $monthsOverflow

Return Value

void

at line 106
void useStrictMode(mixed $strictModeEnabled = 'true')

No description

Parameters

mixed $strictModeEnabled

Return Value

void

at line 106
void useYearsOverflow(mixed $yearsOverflow = 'true')

No description

Parameters

mixed $yearsOverflow

Return Value

void

at line 106
mixed withTestNow(mixed $testNow, callable $callback)

No description

Parameters

mixed $testNow
callable $callback

Return Value

mixed

at line 106
Factory withTimeZone(DateTimeZone|int|string $timezone)

No description

Parameters

DateTimeZone|int|string $timezone

Return Value

Factory

at line 106
CarbonInterface yesterday(DateTimeZone|string|int|null $timezone = 'null')

No description

Parameters

DateTimeZone|string|int|null $timezone

Return Value

CarbonInterface