trait Converter
Trait Converter.
Change date into different string formats and types and handle the string cast.
Depends on the following methods:
Properties
staticprotectedstring|Closure|null | $toStringFormat | Format to use for __toString method when type juggling occurs. |
Methods
Reset the format used to the default when type juggling a Carbon instance to a string
No description
No description
Format the instance as a string using the set format
Format the instance as date
Format the instance as a readable date
Format the instance with the day, and a readable date
Format the instance as time
Format the instance as date and time
Return a format from H:i to H:i:s.u according to given unit precision.
Format the instance as date and time T-separated with no timezone
Format the instance with day, date and time
Format the instance as ATOM
Format the instance as COOKIE
Format the instance as ISO8601
Format the instance as RFC822
Convert the instance to UTC and return as Zulu ISO8601
Format the instance as RFC850
Format the instance as RFC1036
Format the instance as RFC1123
Format the instance as RFC2822
Format the instance as RFC3339
Format the instance as RSS
Format the instance as W3C
Format the instance as RFC7231
Get default array representation.
Get default object representation.
Returns english human readable complete date string.
Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z, if $keepOffset truthy, offset will be kept: 1977-04-22T01:00:00-05:00).
Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z) with UTC timezone.
Return native DateTime PHP object matching the current instance.
Return native toDateTimeImmutable PHP object matching the current instance.
Create a iterable CarbonPeriod object from current date to a given end date (and optional interval).
Create a iterable CarbonPeriod object from current date to a given end date (and optional interval).
No description
Details
at line49
staticvoid
resetToStringFormat()
Reset the format used to the default when type juggling a Carbon instance to a string
at line66
staticvoid
setToStringFormat(string|Closure|null$format)deprecated
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
at line81
format($format)
at line103
string
rawFormat(string$format)
at line118
string
__toString()
Format the instance as a string using the set format
at line141
string
toDateString()
Format the instance as date
at line156
string
toFormattedDateString()
Format the instance as a readable date
at line171
string
toFormattedDayDateString()
Format the instance with the day, and a readable date
at line188
string
toTimeString(string$unitPrecision ='second')
Format the instance as time
at line205
string
toDateTimeString(string$unitPrecision ='second')
Format the instance as date and time
at line217
staticstring
getTimeFormatByPrecision(string$unitPrecision)
Return a format from H:i to H:i:s.u according to given unit precision.
at line249
string
toDateTimeLocalString(string$unitPrecision ='second')
Format the instance as date and time T-separated with no timezone
at line264
string
toDayDateTimeString()
Format the instance with day, date and time
at line279
string
toAtomString()
Format the instance as ATOM
at line294
string
toCookieString()
Format the instance as COOKIE
at line309
string
toIso8601String()
Format the instance as ISO8601
at line324
string
toRfc822String()
Format the instance as RFC822
at line341
string
toIso8601ZuluString(string$unitPrecision ='second')
Convert the instance to UTC and return as Zulu ISO8601
at line358
string
toRfc850String()
Format the instance as RFC850
at line373
string
toRfc1036String()
Format the instance as RFC1036
at line388
string
toRfc1123String()
Format the instance as RFC1123
at line403
string
toRfc2822String()
Format the instance as RFC2822
at line421
string
toRfc3339String(bool$extended =false)
Format the instance as RFC3339
at line441
string
toRssString()
Format the instance as RSS
at line456
string
toW3cString()
Format the instance as W3C
at line471
string
toRfc7231String()
Format the instance as RFC7231
at line488
array
toArray()
Get default array representation.
at line516
object
toObject()
Get default object representation.
at line531
string
toString()
Returns english human readable complete date string.
at line550
null|string
toISOString(bool$keepOffset =false)
Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z, if $keepOffset truthy, offset will be kept: 1977-04-22T01:00:00-05:00).
at line573
null|string
toJSON()
Return the ISO-8601 string (ex: 1977-04-22T06:00:00Z) with UTC timezone.
at line588
DateTime
toDateTime()
Return native DateTime PHP object matching the current instance.
at line603
DateTimeImmutable
toDateTimeImmutable()
Return native toDateTimeImmutable PHP object matching the current instance.
at line620
DateTime
toDate()
at line634
CarbonPeriod
toPeriod(DateTimeInterface|Carbon|CarbonImmutable|int|null$end =null,int|DateInterval|string|null$interval =null,string|null$unit =null)
Create a iterable CarbonPeriod object from current date to a given end date (and optional interval).
at line664
CarbonPeriod
range(DateTimeInterface|Carbon|CarbonImmutable|null$end =null,int|DateInterval|string|null$interval =null,string|null$unit =null)
Create a iterable CarbonPeriod object from current date to a given end date (and optional interval).