class DateFactory (View source)

Constants

DEFAULT_CLASS_NAME

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

Properties

static protected string $dateClass

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

static protected callable $callable

This callable may be used to intercept date creation.

static protected object $factory

The Carbon factory that should be used when creating dates.

Methods

static mixed
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(object $factory)

Use the given Carbon factory when generating dates.

mixed
__call(string $method, array $parameters)

Handle dynamic calls to generate dates.

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

No description

Carbon|null
create(mixed $year, mixed $month, mixed $day, mixed $hour, mixed $minute, mixed $second, mixed $timezone)

No description

createFromDate(mixed $year, mixed $month, mixed $day, mixed $timezone)

No description

Carbon|null
createFromFormat(mixed $format, mixed $time, mixed $timezone)

No description

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

No description

Carbon|null
createFromLocaleFormat(string $format, string $locale, string $time, mixed $timezone)

No description

Carbon|null
createFromLocaleIsoFormat(string $format, string $locale, string $time, mixed $timezone)

No description

createFromTime(mixed $hour, mixed $minute, mixed $second, mixed $timezone)

No description

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

No description

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

No description

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

No description

createFromTimestampMsUTC(mixed $timestamp)

No description

createFromTimestampUTC(string|int|float $timestamp)

No description

createMidnightDate(mixed $year, mixed $month, mixed $day, mixed $timezone)

No description

Carbon|null
createSafe(mixed $year, mixed $month, mixed $day, mixed $hour, mixed $minute, mixed $second, mixed $timezone)

No description

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

No description

void
disableHumanDiffOption(mixed $humanDiffOption)

No description

void
enableHumanDiffOption(mixed $humanDiffOption)

No description

mixed
executeWithLocale(string $locale, callable $func)

No description

fromSerialized(mixed $value)

No description

array
getAvailableLocales()

No description

array
getAvailableLocalesInfo()

No description

array
getDays()

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|null
getTranslationMessageWith(mixed $translator, string $key, ?string $locale = null, ?string $default = null)

No description

Carbon|null
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

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

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

No description

void
mixin(object|string $mixin)

No description

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

No description

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

No description

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

No description

string
pluralUnit(string $unit)

No description

Carbon|null
rawCreateFromFormat(string $format, string $time, mixed $timezone)

No description

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
setFallbackLocale(string $locale)

No description

void
setHumanDiffOptions(mixed $humanDiffOptions)

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)

No description

void
setToStringFormat(Closure|null $format)

No description

void
setTranslator(TranslatorInterface $translator)

No description

void
setWeekEndsAt(mixed $day)

No description

void
setWeekStartsAt(mixed $day)

No description

void
setWeekendDays(mixed $days)

No description

bool
shouldOverflowMonths()

No description

bool
shouldOverflowYears()

No description

string
singularUnit(string $unit)

No description

void
sleep(int|float $seconds)

No description

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

No description

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)

No description

void
useMonthsOverflow(mixed $monthsOverflow)

No description

void
useStrictMode(mixed $strictModeEnabled)

No description

void
useYearsOverflow(mixed $yearsOverflow)

No description

mixed
withTestNow(mixed $testNow, callable $callback)

No description

static void
withTimeZone(DateTimeZone|string|int|null $timezone)

No description

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

No description

Details

static mixed use(mixed $handler)

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

Parameters

mixed $handler

Return Value

mixed

Exceptions

InvalidArgumentException

static void useDefault()

Use the default date class when generating dates.

Return Value

void

static void useCallable(callable $callable)

Execute the given callable on each date creation.

Parameters

callable $callable

Return Value

void

static void useClass(string $dateClass)

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

Parameters

string $dateClass

Return Value

void

static void useFactory(object $factory)

Use the given Carbon factory when generating dates.

Parameters

object $factory

Return Value

void

mixed __call(string $method, array $parameters)

Handle dynamic calls to generate dates.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

RuntimeException

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

No description

Parameters

?string $date
string $format

Return Value

bool

Carbon|null create(mixed $year, mixed $month, mixed $day, mixed $hour, mixed $minute, mixed $second, mixed $timezone)

No description

Parameters

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

Return Value

Carbon|null

Carbon createFromDate(mixed $year, mixed $month, mixed $day, mixed $timezone)

No description

Parameters

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

Return Value

Carbon

Carbon|null createFromFormat(mixed $format, mixed $time, mixed $timezone)

No description

Parameters

mixed $format
mixed $time
mixed $timezone

Return Value

Carbon|null

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

No description

Parameters

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

Return Value

Carbon|null

Carbon|null createFromLocaleFormat(string $format, string $locale, string $time, mixed $timezone)

No description

Parameters

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

Return Value

Carbon|null

Carbon|null createFromLocaleIsoFormat(string $format, string $locale, string $time, mixed $timezone)

No description

Parameters

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

Return Value

Carbon|null

Carbon createFromTime(mixed $hour, mixed $minute, mixed $second, mixed $timezone)

No description

Parameters

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

Return Value

Carbon

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

No description

Parameters

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

Return Value

Carbon

Carbon 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

Carbon

Carbon 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

Carbon

Carbon createFromTimestampMsUTC(mixed $timestamp)

No description

Parameters

mixed $timestamp

Return Value

Carbon

Carbon createFromTimestampUTC(string|int|float $timestamp)

No description

Parameters

string|int|float $timestamp

Return Value

Carbon

Carbon createMidnightDate(mixed $year, mixed $month, mixed $day, mixed $timezone)

No description

Parameters

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

Return Value

Carbon

Carbon|null createSafe(mixed $year, mixed $month, mixed $day, mixed $hour, mixed $minute, mixed $second, mixed $timezone)

No description

Parameters

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

Return Value

Carbon|null

Carbon createStrict(?int $year, ?int $month = 1, ?int $day = 1, ?int $hour, ?int $minute, ?int $second, mixed $timezone)

No description

Parameters

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

Return Value

Carbon

void disableHumanDiffOption(mixed $humanDiffOption)

No description

Parameters

mixed $humanDiffOption

Return Value

void

void enableHumanDiffOption(mixed $humanDiffOption)

No description

Parameters

mixed $humanDiffOption

Return Value

void

mixed executeWithLocale(string $locale, callable $func)

No description

Parameters

string $locale
callable $func

Return Value

mixed

Carbon fromSerialized(mixed $value)

No description

Parameters

mixed $value

Return Value

Carbon

array getAvailableLocales()

No description

Return Value

array

array getAvailableLocalesInfo()

No description

Return Value

array

array getDays()

No description

Return Value

array

array getFormatsToIsoReplacements()

No description

Return Value

array

int getHumanDiffOptions()

No description

Return Value

int

array getIsoUnits()

No description

Return Value

array

array|false getLastErrors()

No description

Return Value

array|false

string getLocale()

No description

Return Value

string

int getMidDayAt()

No description

Return Value

int

string getTimeFormatByPrecision(string $unitPrecision)

No description

Parameters

string $unitPrecision

Return Value

string

Closure|null 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|null

Carbon|null getTestNow()

No description

Return Value

Carbon|null

TranslatorInterface getTranslator()

No description

Return Value

TranslatorInterface

int getWeekEndsAt(?string $locale = null)

No description

Parameters

?string $locale

Return Value

int

int getWeekStartsAt(?string $locale = null)

No description

Parameters

?string $locale

Return Value

int

array getWeekendDays()

No description

Return Value

array

bool hasFormat(string $date, string $format)

No description

Parameters

string $date
string $format

Return Value

bool

bool hasFormatWithModifiers(string $date, string $format)

No description

Parameters

string $date
string $format

Return Value

bool

bool hasMacro(mixed $name)

No description

Parameters

mixed $name

Return Value

bool

bool hasRelativeKeywords(?string $time)

No description

Parameters

?string $time

Return Value

bool

bool hasTestNow()

No description

Return Value

bool

Carbon instance(DateTimeInterface $date)

No description

Parameters

DateTimeInterface $date

Return Value

Carbon

bool isImmutable()

No description

Return Value

bool

bool isModifiableUnit(mixed $unit)

No description

Parameters

mixed $unit

Return Value

bool

bool isMutable()

No description

Return Value

bool

bool isStrictModeEnabled()

No description

Return Value

bool

bool localeHasDiffOneDayWords(string $locale)

No description

Parameters

string $locale

Return Value

bool

bool localeHasDiffSyntax(string $locale)

No description

Parameters

string $locale

Return Value

bool

bool localeHasDiffTwoDayWords(string $locale)

No description

Parameters

string $locale

Return Value

bool

bool localeHasPeriodSyntax(mixed $locale)

No description

Parameters

mixed $locale

Return Value

bool

bool localeHasShortUnits(string $locale)

No description

Parameters

string $locale

Return Value

bool

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

No description

Parameters

string $name
?callable $macro

Return Value

void

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

No description

Parameters

mixed $var
DateTimeZone|string|null $timezone

Return Value

Carbon|null

void mixin(object|string $mixin)

No description

Parameters

object|string $mixin

Return Value

void

Carbon now(DateTimeZone|string|int|null $timezone = null)

No description

Parameters

DateTimeZone|string|int|null $timezone

Return Value

Carbon

Carbon 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

Carbon

Carbon 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

Carbon

string pluralUnit(string $unit)

No description

Parameters

string $unit

Return Value

string

Carbon|null rawCreateFromFormat(string $format, string $time, mixed $timezone)

No description

Parameters

string $format
string $time
mixed $timezone

Return Value

Carbon|null

Carbon 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

Carbon

void resetMonthsOverflow()

No description

Return Value

void

void resetToStringFormat()

No description

Return Value

void

void resetYearsOverflow()

No description

Return Value

void

void serializeUsing(mixed $callback)

No description

Parameters

mixed $callback

Return Value

void

void setFallbackLocale(string $locale)

No description

Parameters

string $locale

Return Value

void

void setHumanDiffOptions(mixed $humanDiffOptions)

No description

Parameters

mixed $humanDiffOptions

Return Value

void

void setLocale(string $locale)

No description

Parameters

string $locale

Return Value

void

void setMidDayAt(mixed $hour)

No description

Parameters

mixed $hour

Return Value

void

void setTestNow(mixed $testNow = null)

No description

Parameters

mixed $testNow

Return Value

void

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

No description

Parameters

mixed $testNow
mixed $timezone

Return Value

void

void setToStringFormat(Closure|null $format)

No description

Parameters

Closure|null $format

Return Value

void

void setTranslator(TranslatorInterface $translator)

No description

Parameters

TranslatorInterface $translator

Return Value

void

void setWeekEndsAt(mixed $day)

No description

Parameters

mixed $day

Return Value

void

void setWeekStartsAt(mixed $day)

No description

Parameters

mixed $day

Return Value

void

void setWeekendDays(mixed $days)

No description

Parameters

mixed $days

Return Value

void

bool shouldOverflowMonths()

No description

Return Value

bool

bool shouldOverflowYears()

No description

Return Value

bool

string singularUnit(string $unit)

No description

Parameters

string $unit

Return Value

string

void sleep(int|float $seconds)

No description

Parameters

int|float $seconds

Return Value

void

Carbon today(DateTimeZone|string|int|null $timezone = null)

No description

Parameters

DateTimeZone|string|int|null $timezone

Return Value

Carbon

Carbon tomorrow(DateTimeZone|string|int|null $timezone = null)

No description

Parameters

DateTimeZone|string|int|null $timezone

Return Value

Carbon

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

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

No description

Parameters

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

Return Value

string

void useMonthsOverflow(mixed $monthsOverflow)

No description

Parameters

mixed $monthsOverflow

Return Value

void

void useStrictMode(mixed $strictModeEnabled)

No description

Parameters

mixed $strictModeEnabled

Return Value

void

void useYearsOverflow(mixed $yearsOverflow)

No description

Parameters

mixed $yearsOverflow

Return Value

void

mixed withTestNow(mixed $testNow, callable $callback)

No description

Parameters

mixed $testNow
callable $callback

Return Value

mixed

static void withTimeZone(DateTimeZone|string|int|null $timezone)

No description

Parameters

DateTimeZone|string|int|null $timezone

Return Value

void

Carbon yesterday(DateTimeZone|string|int|null $timezone = null)

No description

Parameters

DateTimeZone|string|int|null $timezone

Return Value

Carbon