FileAccess Orion

Factory
in package

A factory to generate Carbon instances with common settings.

<autodoc generated by composer phpdoc>

Table of Contents

$className  : mixed
$settings  : mixed
__call()  : mixed
__construct()  : mixed
className()  : mixed
create()  : Carbon
createFromDate()  : Carbon
createFromFormat()  : Carbon|false
createFromIsoFormat()  : Carbon|false
createFromLocaleFormat()  : Carbon|false
createFromLocaleIsoFormat()  : Carbon|false
createFromTime()  : Carbon
createFromTimestamp()  : Carbon
createFromTimestampMs()  : Carbon
createFromTimestampUTC()  : Carbon
createFromTimeString()  : Carbon
createMidnightDate()  : Carbon
createSafe()  : Carbon|false
disableHumanDiffOption()  : Carbon
enableHumanDiffOption()  : Carbon
executeWithLocale()  : mixed
fromSerialized()  : Carbon
genericMacro()  : void
getAvailableLocales()  : array<string|int, mixed>
getAvailableLocalesInfo()  : array<string|int, Language>
getClassName()  : mixed
getDays()  : array<string|int, mixed>
getFallbackLocale()  : string|null
getFormatsToIsoReplacements()  : array<string|int, mixed>
getHumanDiffOptions()  : int
getIsoUnits()  : array<string|int, mixed>
getLastErrors()  : Carbon
getLocale()  : string
getMacro()  : callable|null
getMidDayAt()  : int
getSettings()  : mixed
getTestNow()  : Closure|Carbon
getTimeFormatByPrecision()  : string
getTranslationMessageWith()  : string
getTranslator()  : TranslatorInterface
getWeekendDays()  : array<string|int, mixed>
getWeekEndsAt()  : int
getWeekStartsAt()  : int
hasFormat()  : bool
hasMacro()  : bool
hasRelativeKeywords()  : bool
hasTestNow()  : bool
instance()  : Carbon
isImmutable()  : bool
isModifiableUnit()  : bool
isMutable()  : bool
isStrictModeEnabled()  : bool
localeHasDiffOneDayWords()  : bool
localeHasDiffSyntax()  : bool
localeHasDiffTwoDayWords()  : bool
localeHasPeriodSyntax()  : bool
localeHasShortUnits()  : bool
macro()  : void
make()  : Carbon|null
maxValue()  : Carbon
mergeSettings()  : mixed
minValue()  : Carbon
mixin()  : void
now()  : Carbon
parse()  : Carbon
parseFromLocale()  : Carbon
pluralUnit()  : string
rawCreateFromFormat()  : Carbon|false
rawParse()  : Carbon
resetMacros()  : Carbon
resetMonthsOverflow()  : void
resetToStringFormat()  : void
resetYearsOverflow()  : void
serializeUsing()  : void
setClassName()  : mixed
setFallbackLocale()  : Carbon
setHumanDiffOptions()  : Carbon
setLocale()  : bool
setMidDayAt()  : void
setSettings()  : mixed
setTestNow()  : Carbon
settings()  : mixed
setToStringFormat()  : void
setTranslator()  : void
setUtf8()  : Carbon
setWeekendDays()  : void
setWeekEndsAt()  : void
setWeekStartsAt()  : void
shouldOverflowMonths()  : bool
shouldOverflowYears()  : bool
singularUnit()  : string
today()  : Carbon
tomorrow()  : Carbon
translateTimeString()  : string
translateWith()  : string
useMonthsOverflow()  : void
useStrictMode()  : Carbon
useYearsOverflow()  : void
yesterday()  : Carbon

Properties

$className

protected mixed $className = \Carbon\Carbon::class

$settings

protected mixed $settings = []

Methods

__call()

public __call(mixed $name, mixed $arguments) : mixed
Parameters
$name : mixed
$arguments : mixed
Return values
mixed

__construct()

public __construct([array<string|int, mixed> $settings = [] ][, string $className = null ]) : mixed
Parameters
$settings : array<string|int, mixed> = []
$className : string = null
Return values
mixed

className()

public className([string $className = null ]) : mixed
Parameters
$className : string = null
Return values
mixed

create()

public create(mixed $year, mixed $month, mixed $day, mixed $hour, mixed $minute, mixed $second, mixed $tz) : Carbon

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.

Parameters
$year : mixed
$month : mixed
$day : mixed
$hour : mixed
$minute : mixed
$second : mixed
$tz : mixed
Return values
Carbon

createFromDate()

public createFromDate(mixed $year, mixed $month, mixed $day, mixed $tz) : Carbon

Create a Carbon instance from just a date. The time portion is set to now.

Parameters
$year : mixed
$month : mixed
$day : mixed
$tz : mixed
Return values
Carbon

createFromFormat()

public createFromFormat(mixed $format, mixed $time, mixed $tz) : Carbon|false

Create a Carbon instance from a specific format.

Parameters
$format : mixed
$time : mixed
$tz : mixed
Return values
Carbon|false

createFromIsoFormat()

public createFromIsoFormat(mixed $format, mixed $time, mixed $tz, mixed $locale, mixed $translator) : Carbon|false

Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).

Parameters
$format : mixed
$time : mixed
$tz : mixed
$locale : mixed
$translator : mixed
Return values
Carbon|false

createFromLocaleFormat()

public createFromLocaleFormat(mixed $format, mixed $locale, mixed $time, mixed $tz) : Carbon|false

Create a Carbon instance from a specific format and a string in a given language.

Parameters
$format : mixed
$locale : mixed
$time : mixed
$tz : mixed
Return values
Carbon|false

createFromLocaleIsoFormat()

public createFromLocaleIsoFormat(mixed $format, mixed $locale, mixed $time, mixed $tz) : Carbon|false

Create a Carbon instance from a specific ISO format and a string in a given language.

Parameters
$format : mixed
$locale : mixed
$time : mixed
$tz : mixed
Return values
Carbon|false

createFromTime()

public createFromTime(mixed $hour, mixed $minute, mixed $second, mixed $tz) : Carbon

Create a Carbon instance from just a time. The date portion is set to today.

Parameters
$hour : mixed
$minute : mixed
$second : mixed
$tz : mixed
Return values
Carbon

createFromTimestamp()

public createFromTimestamp(mixed $timestamp, mixed $tz) : Carbon

Create a Carbon instance from a timestamp.

Parameters
$timestamp : mixed
$tz : mixed
Return values
Carbon

createFromTimestampMs()

public createFromTimestampMs(mixed $timestamp, mixed $tz) : Carbon

Create a Carbon instance from a timestamp in milliseconds.

Parameters
$timestamp : mixed
$tz : mixed
Return values
Carbon

createFromTimestampUTC()

public createFromTimestampUTC(mixed $timestamp) : Carbon

Create a Carbon instance from an UTC timestamp.

Parameters
$timestamp : mixed
Return values
Carbon

createFromTimeString()

public createFromTimeString(mixed $time, mixed $tz) : Carbon

Create a Carbon instance from a time string. The date portion is set to today.

Parameters
$time : mixed
$tz : mixed
Return values
Carbon

createMidnightDate()

public createMidnightDate(mixed $year, mixed $month, mixed $day, mixed $tz) : Carbon

Create a Carbon instance from just a date. The time portion is set to midnight.

Parameters
$year : mixed
$month : mixed
$day : mixed
$tz : mixed
Return values
Carbon

createSafe()

public createSafe(mixed $year, mixed $month, mixed $day, mixed $hour, mixed $minute, mixed $second, mixed $tz) : Carbon|false

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 InvalidDateException will be thrown.

Parameters
$year : mixed
$month : mixed
$day : mixed
$hour : mixed
$minute : mixed
$second : mixed
$tz : mixed
Return values
Carbon|false

disableHumanDiffOption()

public disableHumanDiffOption(mixed $humanDiffOption) : Carbon

@deprecated To avoid conflict between different third-party libraries, static setters should not be used. You should rather use the ->settings() method.

Parameters
$humanDiffOption : mixed
Return values
Carbon

enableHumanDiffOption()

public enableHumanDiffOption(mixed $humanDiffOption) : Carbon

@deprecated To avoid conflict between different third-party libraries, static setters should not be used. You should rather use the ->settings() method.

Parameters
$humanDiffOption : mixed
Return values
Carbon

executeWithLocale()

public executeWithLocale(mixed $locale, mixed $func) : mixed

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).

Parameters
$locale : mixed
$func : mixed
Return values
mixed

fromSerialized()

public fromSerialized(mixed $value) : Carbon

Create an instance from a serialized string.

Parameters
$value : mixed
Return values
Carbon

genericMacro()

public genericMacro(mixed $macro, mixed $priority) : void

Register a custom macro.

Parameters
$macro : mixed
$priority : mixed
Return values
void

getAvailableLocales()

public getAvailableLocales() : array<string|int, mixed>

Returns the list of internally available locales and already loaded custom locales. (It will ignore custom translator dynamic loading.)

Return values
array<string|int, mixed>

getAvailableLocalesInfo()

public getAvailableLocalesInfo() : array<string|int, Language>

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 values
array<string|int, Language>

getClassName()

public getClassName() : mixed
Return values
mixed

getDays()

public getDays() : array<string|int, mixed>

Get the days of the week

Return values
array<string|int, mixed>

getFallbackLocale()

public getFallbackLocale() : string|null

Get the fallback locale.

Return values
string|null

getFormatsToIsoReplacements()

public getFormatsToIsoReplacements() : array<string|int, mixed>

List of replacements from date() format to isoFormat().

Return values
array<string|int, mixed>

getHumanDiffOptions()

public getHumanDiffOptions() : int

Return default humanDiff() options (merged flags as integer).

Return values
int

getIsoUnits()

public getIsoUnits() : array<string|int, mixed>

Returns list of locale units for ISO formatting.

Return values
array<string|int, mixed>

getLocale()

public getLocale() : string

Get the current translator locale.

Return values
string

getMacro()

public getMacro(mixed $name) : callable|null

Get the raw callable macro registered globally for a given name.

Parameters
$name : mixed
Return values
callable|null

getMidDayAt()

public getMidDayAt() : int

get midday/noon hour

Return values
int

getSettings()

public getSettings() : mixed
Return values
mixed

getTestNow()

public getTestNow() : Closure|Carbon

Get the Carbon instance (real or mock) to be returned when a "now" instance is created.

Return values
Closure|Carbon

getTimeFormatByPrecision()

public getTimeFormatByPrecision(mixed $unitPrecision) : string

Return a format from H:i to H:i:s.u according to given unit precision.

Parameters
$unitPrecision : mixed
Return values
string

getTranslationMessageWith()

public getTranslationMessageWith(mixed $translator, string $key, string $locale = null, string $default = null) : string

Returns raw translation message for a given key.

Parameters
$translator : mixed
$key : string
$locale = null : string
$default = null : string
Return values
string

getWeekendDays()

public getWeekendDays() : array<string|int, mixed>

Get weekend days

Return values
array<string|int, mixed>

getWeekEndsAt()

public getWeekEndsAt() : int

Get the last day of week

Return values
int

getWeekStartsAt()

public getWeekStartsAt() : int

Get the first day of week

Return values
int

hasFormat()

public hasFormat(mixed $date, mixed $format) : bool

Checks if the (date)time string is in a given format.

Parameters
$date : mixed
$format : mixed
Return values
bool

hasMacro()

public hasMacro(mixed $name) : bool

Checks if macro is registered globally.

Parameters
$name : mixed
Return values
bool

hasRelativeKeywords()

public hasRelativeKeywords(mixed $time) : bool

Determine if a time string will produce a relative date.

Parameters
$time : mixed
Return values
bool

hasTestNow()

public hasTestNow() : bool

Determine if there is a valid test instance set. A valid test instance is anything that is not null.

Return values
bool

instance()

public instance(mixed $date) : Carbon

Create a Carbon instance from a DateTime one.

Parameters
$date : mixed
Return values
Carbon

isImmutable()

public isImmutable() : bool

Returns true if the current class/instance is immutable.

Return values
bool

isModifiableUnit()

public isModifiableUnit(mixed $unit) : bool

Returns true if a property can be changed via setter.

Parameters
$unit : mixed
Return values
bool

isMutable()

public isMutable() : bool

Returns true if the current class/instance is mutable.

Return values
bool

isStrictModeEnabled()

public isStrictModeEnabled() : bool

Returns true if the strict mode is globally in use, false else. (It can be overridden in specific instances.)

Return values
bool

localeHasDiffOneDayWords()

public localeHasDiffOneDayWords(mixed $locale) : bool

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.

Parameters
$locale : mixed
Return values
bool

localeHasDiffSyntax()

public localeHasDiffSyntax(mixed $locale) : bool

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.

Parameters
$locale : mixed
Return values
bool

localeHasDiffTwoDayWords()

public localeHasDiffTwoDayWords(mixed $locale) : bool

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.

Parameters
$locale : mixed
Return values
bool

localeHasPeriodSyntax()

public localeHasPeriodSyntax(mixed $locale) : bool

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.

Parameters
$locale : mixed
Return values
bool

localeHasShortUnits()

public localeHasShortUnits(mixed $locale) : bool

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.

Parameters
$locale : mixed
Return values
bool

macro()

public macro(mixed $name, mixed $macro) : void

Register a custom macro.

Parameters
$name : mixed
$macro : mixed
Return values
void

make()

public make(mixed $var) : Carbon|null

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.

Parameters
$var : mixed
Return values
Carbon|null

maxValue()

public maxValue() : Carbon

Create a Carbon instance for the greatest supported date.

Return values
Carbon

mergeSettings()

public mergeSettings(array<string|int, mixed> $settings) : mixed
Parameters
$settings : array<string|int, mixed>
Return values
mixed

minValue()

public minValue() : Carbon

Create a Carbon instance for the lowest supported date.

Return values
Carbon

mixin()

public mixin(mixed $mixin) : void

Mix another object into the class.

Parameters
$mixin : mixed
Return values
void

now()

public now(mixed $tz) : Carbon

Get a Carbon instance for the current date and time.

Parameters
$tz : mixed
Return values
Carbon

parse()

public parse(mixed $time, mixed $tz) : Carbon

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().

Parameters
$time : mixed
$tz : mixed
Return values
Carbon

parseFromLocale()

public parseFromLocale(mixed $time, mixed $locale, mixed $tz) : Carbon

Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).

Parameters
$time : mixed
$locale : mixed
$tz : mixed
Return values
Carbon

pluralUnit()

public pluralUnit(string $unit) : string

Returns standardized plural of a given singular/plural unit name (in English).

Parameters
$unit : string
Return values
string

rawCreateFromFormat()

public rawCreateFromFormat(mixed $format, mixed $time, mixed $tz) : Carbon|false

Create a Carbon instance from a specific format.

Parameters
$format : mixed
$time : mixed
$tz : mixed
Return values
Carbon|false

rawParse()

public rawParse(mixed $time, mixed $tz) : Carbon

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().

Parameters
$time : mixed
$tz : mixed
Return values
Carbon

resetMacros()

public resetMacros() : Carbon

Remove all macros and generic macros.

Return values
Carbon

resetMonthsOverflow()

public resetMonthsOverflow() : void

@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).

Return values
void

resetToStringFormat()

public resetToStringFormat() : void

Reset the format used to the default when type juggling a Carbon instance to a string

Return values
void

resetYearsOverflow()

public resetYearsOverflow() : void

@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).

Return values
void

serializeUsing()

public serializeUsing(mixed $callback) : void

@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.

Parameters
$callback : mixed
Return values
void

setClassName()

public setClassName(string $className) : mixed
Parameters
$className : string
Return values
mixed

setFallbackLocale()

public setFallbackLocale(mixed $locale) : Carbon

Set the fallback locale.

Parameters
$locale : mixed
Return values
Carbon

setHumanDiffOptions()

public setHumanDiffOptions(mixed $humanDiffOptions) : Carbon

@deprecated To avoid conflict between different third-party libraries, static setters should not be used. You should rather use the ->settings() method.

Parameters
$humanDiffOptions : mixed
Return values
Carbon

setLocale()

public setLocale(mixed $locale) : bool

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.

Parameters
$locale : mixed
Return values
bool

setMidDayAt()

public setMidDayAt(mixed $hour) : void

@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

Parameters
$hour : mixed
Return values
void

setSettings()

public setSettings(array<string|int, mixed> $settings) : mixed
Parameters
$settings : array<string|int, mixed>
Return values
mixed

setTestNow()

public setTestNow(mixed $testNow) : Carbon

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.
Parameters
$testNow : mixed
Return values
Carbon

settings()

public settings([array<string|int, mixed> $settings = null ]) : mixed
Parameters
$settings : array<string|int, mixed> = null
Return values
mixed

setToStringFormat()

public setToStringFormat(mixed $format) : void

@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

Parameters
$format : mixed
Return values
void

setUtf8()

public setUtf8(mixed $utf8) : Carbon

@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.

Parameters
$utf8 : mixed
Return values
Carbon

setWeekendDays()

public setWeekendDays(mixed $days) : void

@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

Parameters
$days : mixed
Return values
void

setWeekEndsAt()

public setWeekEndsAt(mixed $day) : void

@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

Parameters
$day : mixed
Return values
void

setWeekStartsAt()

public setWeekStartsAt(mixed $day) : void

@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

Parameters
$day : mixed
Return values
void

shouldOverflowMonths()

public shouldOverflowMonths() : bool

Get the month overflow global behavior (can be overridden in specific instances).

Return values
bool

shouldOverflowYears()

public shouldOverflowYears() : bool

Get the month overflow global behavior (can be overridden in specific instances).

Return values
bool

singularUnit()

public singularUnit(string $unit) : string

Returns standardized singular of a given singular/plural unit name (in English).

Parameters
$unit : string
Return values
string

today()

public today(mixed $tz) : Carbon

Create a Carbon instance for today.

Parameters
$tz : mixed
Return values
Carbon

tomorrow()

public tomorrow(mixed $tz) : Carbon

Create a Carbon instance for tomorrow.

Parameters
$tz : mixed
Return values
Carbon

translateTimeString()

public translateTimeString(mixed $timeString, mixed $from, mixed $to, mixed $mode) : string

Translate a time string from a locale to an other.

Parameters
$timeString : mixed
$from : mixed
$to : mixed
$mode : mixed
Return values
string

translateWith()

public translateWith(TranslatorInterface $translator, string $key, array<string|int, mixed> $parameters = [], mixed $number) : string

Translate using translation string or callback available.

Parameters
$translator : TranslatorInterface
$key : string
$parameters = [] : array<string|int, mixed>
$number : mixed
Return values
string

useMonthsOverflow()

public useMonthsOverflow(mixed $monthsOverflow) : void

@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).

Parameters
$monthsOverflow : mixed
Return values
void

useStrictMode()

public useStrictMode(mixed $strictModeEnabled) : Carbon

@deprecated To avoid conflict between different third-party libraries, static setters should not be used. You should rather use the ->settings() method.

Parameters
$strictModeEnabled : mixed
Return values
Carbon

useYearsOverflow()

public useYearsOverflow(mixed $yearsOverflow) : void

@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).

Parameters
$yearsOverflow : mixed
Return values
void

yesterday()

public yesterday(mixed $tz) : Carbon

Create a Carbon instance for yesterday.

Parameters
$tz : mixed
Return values
Carbon

Search results