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