class Factory
A factory to generate Carbon instances with common settings.
Properties
protected | $className | ||
protected | $settings |
Methods
No description
No description
No description
No description
No description
No description
No description
No description
No description
Checks if the (date)time string is in a given format and valid to create a
Create a new Carbon instance from a specific date and time.
Create a Carbon instance from just a date. The time portion is set to now.
Create a Carbon instance from a specific format.
Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).
Create a Carbon instance from a specific format and a string in a given language.
Create a Carbon instance from a specific ISO format and a string in a given language.
Create a Carbon instance from just a time. The date portion is set to today.
Create a Carbon instance from a time string. The date portion is set to today.
Create a Carbon instance from a timestamp and set the timezone (use default one if not specified).
Create a Carbon instance from a timestamp in milliseconds.
Create a Carbon instance from a timestamp in milliseconds.
Create a Carbon instance from an timestamp keeping the timezone to UTC.
Create a Carbon instance from just a date. The time portion is set to midnight.
Create a new safe Carbon instance from a specific date and time.
Create a new Carbon instance from a specific date and time using strict validation.
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
Set the current locale to the given, execute the passed function, reset the locale to previous one,
Create an instance from a serialized string.
Register a custom macro.
Returns the list of internally available locales and already loaded custom locales.
Get the days of the week
Get the fallback locale.
List of replacements from date() format to isoFormat().
Return default humanDiff() options (merged flags as integer).
Returns list of locale units for ISO formatting.
{@inheritdoc}
Get the current translator locale.
Get the raw callable macro registered globally for a given name.
get midday/noon hour
Get the Carbon instance (real or mock) to be returned when a "now"
Return a format from H:i to H:i:s.u according to given unit precision.
Returns raw translation message for a given key.
Get the default translator instance in use.
Get the last day of week
Get the first day of week
Get weekend days
Checks if the (date)time string is in a given format.
Checks if the (date)time string is in a given format.
Checks if macro is registered globally.
Determine if a time string will produce a relative date.
Determine if there is a valid test instance set. A valid test instance
Create a Carbon instance from a DateTime one.
Returns true if the current class/instance is immutable.
Returns true if a property can be changed via setter.
Returns true if the current class/instance is mutable.
Returns true if the strict mode is globally in use, false else.
Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
Returns true if the given locale is internally supported and has short-units support.
Register a custom macro.
Make a Carbon instance from given variable if possible.
Create a Carbon instance for the greatest supported date.
Create a Carbon instance for the lowest supported date.
Mix another object into the class.
Get a Carbon instance for the current date and time.
Create a carbon instance from a string.
Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).
Returns standardized plural of a given singular/plural unit name (in English).
Create a Carbon instance from a specific format.
Create a carbon instance from a string.
Remove all macros and generic macros.
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
Reset the format used to the default when type juggling a Carbon instance to a string
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
Set the fallback locale.
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
Set the current translator locale and indicate if the source locale file exists.
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
Set a Carbon instance (real or mock) to be returned when a "now"
Set a Carbon instance (real or mock) to be returned when a "now"
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
Set the default translator instance to use.
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
Get the month overflow global behavior (can be overridden in specific instances).
Get the month overflow global behavior (can be overridden in specific instances).
Returns standardized singular of a given singular/plural unit name (in English).
Create a Carbon instance for today.
Create a Carbon instance for tomorrow.
Translate a time string from a locale to an other.
Translate using translation string or callback available.
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
Temporarily sets a static date to be used within the callback.
Create a Carbon instance for yesterday.
Details
at line248
__construct(array$settings =[],string|null$className =null)
at line257
getClassName()
at line262
setClassName(string$className)
at line269
className(string$className =null)
at line274
getSettings()
at line279
setSettings(array$settings)
at line286
settings(array$settings =null)
at line291
mergeSettings(array$settings)
at line298
__call($name,$arguments)
at line242
bool
canBeCreatedFromFormat($date,$format)
Checks if the (date)time string is in a given format and valid to create a
at line242
Carbon|false
create($year,$month =1,$day =1,$hour,$minute,$second,$tz =null)
Create a new Carbon instance from a specific date and time.
at line242
Carbon
createFromDate($year =null,$month =null,$day =null,$tz =null)
Create a Carbon instance from just a date. The time portion is set to now.
at line242
Carbon|false
createFromFormat($format,$time,$tz =null)
Create a Carbon instance from a specific format.
at line242
Carbon|false
createFromIsoFormat($format,$time,$tz =null,$locale ='en',$translator =null)
Create a Carbon instance from a specific ISO format (same replacements as ->isoFormat()).
at line242
Carbon|false
createFromLocaleFormat($format,$locale,$time,$tz =null)
Create a Carbon instance from a specific format and a string in a given language.
at line242
Carbon|false
createFromLocaleIsoFormat($format,$locale,$time,$tz =null)
Create a Carbon instance from a specific ISO format and a string in a given language.
at line242
Carbon
createFromTime($hour,$minute,$second,$tz =null)
Create a Carbon instance from just a time. The date portion is set to today.
at line242
Carbon
createFromTimeString($time,$tz =null)
Create a Carbon instance from a time string. The date portion is set to today.
at line242
Carbon
createFromTimestamp($timestamp,$tz =null)
Create a Carbon instance from a timestamp and set the timezone (use default one if not specified).
at line242
Carbon
createFromTimestampMs($timestamp,$tz =null)
Create a Carbon instance from a timestamp in milliseconds.
at line242
Carbon
createFromTimestampMsUTC($timestamp)
Create a Carbon instance from a timestamp in milliseconds.
at line242
Carbon
createFromTimestampUTC($timestamp)
Create a Carbon instance from an timestamp keeping the timezone to UTC.
at line242
Carbon
createMidnightDate($year =null,$month =null,$day =null,$tz =null)
Create a Carbon instance from just a date. The time portion is set to midnight.
at line242
Carbon|false
createSafe($year =null,$month =null,$day =null,$hour =null,$minute =null,$second =null,$tz =null)
Create a new safe Carbon instance from a specific date and time.
at line242
CarbonInterface
createStrict($tz =null)
Create a new Carbon instance from a specific date and time using strict validation.
at line242
Carbon
disableHumanDiffOption($humanDiffOption)
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
Carbon
enableHumanDiffOption($humanDiffOption)
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
mixed
executeWithLocale($locale,$func)
Set the current locale to the given, execute the passed function, reset the locale to previous one,
at line242
Carbon
fromSerialized($value)
Create an instance from a serialized string.
at line242
void
genericMacro($macro,$priority)
Register a custom macro.
at line242
array
getAvailableLocales()
Returns the list of internally available locales and already loaded custom locales.
at line242
array
getDays()
Get the days of the week
at line242
string|null
getFallbackLocale()
Get the fallback locale.
at line242
array
getFormatsToIsoReplacements()
List of replacements from date() format to isoFormat().
at line242
int
getHumanDiffOptions()
Return default humanDiff() options (merged flags as integer).
at line242
array
getIsoUnits()
Returns list of locale units for ISO formatting.
at line242
array
getLastErrors()
{@inheritdoc}
at line242
string
getLocale()
Get the current translator locale.
at line242
callable|null
getMacro($name)
Get the raw callable macro registered globally for a given name.
at line242
int
getMidDayAt()
get midday/noon hour
at line242
Closure|Carbon
getTestNow()
Get the Carbon instance (real or mock) to be returned when a "now"
at line242
string
getTimeFormatByPrecision($unitPrecision)
Return a format from H:i to H:i:s.u according to given unit precision.
at line242
string
getTranslationMessageWith($translator,string $key)
Returns raw translation message for a given key.
at line242
TranslatorInterface
getTranslator()
Get the default translator instance in use.
at line242
int
getWeekEndsAt()
Get the last day of week
at line242
int
getWeekStartsAt()
Get the first day of week
at line242
array
getWeekendDays()
Get weekend days
at line242
bool
hasFormat($date,$format)
Checks if the (date)time string is in a given format.
at line242
bool
hasFormatWithModifiers($date,$format)
Checks if the (date)time string is in a given format.
at line242
bool
hasMacro($name)
Checks if macro is registered globally.
at line242
bool
hasRelativeKeywords($time)
Determine if a time string will produce a relative date.
at line242
bool
hasTestNow()
Determine if there is a valid test instance set. A valid test instance
at line242
Carbon
instance($date)
Create a Carbon instance from a DateTime one.
at line242
bool
isImmutable()
Returns true if the current class/instance is immutable.
at line242
bool
isModifiableUnit($unit)
Returns true if a property can be changed via setter.
at line242
bool
isMutable()
Returns true if the current class/instance is mutable.
at line242
bool
isStrictModeEnabled()
Returns true if the strict mode is globally in use, false else.
at line242
bool
localeHasDiffOneDayWords($locale)
Returns true if the given locale is internally supported and has words for 1-day diff (just now, yesterday, tomorrow).
at line242
bool
localeHasDiffSyntax($locale)
Returns true if the given locale is internally supported and has diff syntax support (ago, from now, before, after).
at line242
bool
localeHasDiffTwoDayWords($locale)
Returns true if the given locale is internally supported and has words for 2-days diff (before yesterday, after tomorrow).
at line242
bool
localeHasPeriodSyntax($locale)
Returns true if the given locale is internally supported and has period syntax support (X times, every X, from X, to X).
at line242
bool
localeHasShortUnits($locale)
Returns true if the given locale is internally supported and has short-units support.
at line242
void
macro($name,$macro)
Register a custom macro.
at line242
Carbon|null
make($var)
Make a Carbon instance from given variable if possible.
at line242
Carbon
maxValue()
Create a Carbon instance for the greatest supported date.
at line242
Carbon
minValue()
Create a Carbon instance for the lowest supported date.
at line242
void
mixin($mixin)
Mix another object into the class.
at line242
Carbon
now($tz =null)
Get a Carbon instance for the current date and time.
at line242
Carbon
parse($time =null,$tz =null)
Create a carbon instance from a string.
at line242
Carbon
parseFromLocale($time,$locale =null,$tz =null)
Create a carbon instance from a localized string (in French, Japanese, Arabic, etc.).
at line242
string
pluralUnit(string $unit)
Returns standardized plural of a given singular/plural unit name (in English).
at line242
Carbon|false
rawCreateFromFormat($format,$time,$tz =null)
Create a Carbon instance from a specific format.
at line242
Carbon
rawParse($time =null,$tz =null)
Create a carbon instance from a string.
at line242
Carbon
resetMacros()
Remove all macros and generic macros.
at line242
void
resetMonthsOverflow()
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
void
resetToStringFormat()
Reset the format used to the default when type juggling a Carbon instance to a string
at line242
void
resetYearsOverflow()
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
void
serializeUsing($callback)
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
Carbon
setFallbackLocale($locale)
Set the fallback locale.
at line242
Carbon
setHumanDiffOptions($humanDiffOptions)
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
bool
setLocale($locale)
Set the current translator locale and indicate if the source locale file exists.
at line242
void
setMidDayAt($hour)
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
Carbon
setTestNow($testNow =null)
Set a Carbon instance (real or mock) to be returned when a "now"
at line242
Carbon
setTestNowAndTimezone($testNow =null,$tz =null)
Set a Carbon instance (real or mock) to be returned when a "now"
at line242
void
setToStringFormat($format)
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
void
setTranslator(TranslatorInterface $translator)
Set the default translator instance to use.
at line242
Carbon
setUtf8($utf8)
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
void
setWeekEndsAt($day)
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
void
setWeekStartsAt($day)
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
void
setWeekendDays($days)
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
bool
shouldOverflowMonths()
Get the month overflow global behavior (can be overridden in specific instances).
at line242
bool
shouldOverflowYears()
Get the month overflow global behavior (can be overridden in specific instances).
at line242
string
singularUnit(string $unit)
Returns standardized singular of a given singular/plural unit name (in English).
at line242
Carbon
today($tz =null)
Create a Carbon instance for today.
at line242
Carbon
tomorrow($tz =null)
Create a Carbon instance for tomorrow.
at line242
string
translateTimeString($timeString,$from =null,$to =null,$mode =CarbonInterface::TRANSLATE_ALL)
Translate a time string from a locale to an other.
at line242
string
translateWith(TranslatorInterface $translator,string $key,array $parameters =[],$number =null)
Translate using translation string or callback available.
at line242
void
useMonthsOverflow($monthsOverflow =true)
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
Carbon
useStrictMode($strictModeEnabled =true)
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
void
useYearsOverflow($yearsOverflow =true)
@deprecated To avoid conflict between different third-party libraries, static setters should not be used.
at line242
mixed
withTestNow($testNow =null,$callback =null)
Temporarily sets a static date to be used within the callback.
at line242
Carbon
yesterday($tz =null)
Create a Carbon instance for yesterday.