FormattingTrait
Provides string formatting methods for datetime instances.
Expects implementing classes to define static::$toStringFormat
Table of Contents
Methods
- __toString() : string
- Format the instance as a string using the set format
- resetToStringFormat() : void
- Reset the format used to the default when type juggling a ChronosInterface instance to a string
- setToStringFormat() : void
- Set the default format used when type juggling a ChronosInterface instance to a string
- toAtomString() : string
- Format the instance as ATOM
- toCookieString() : string
- Format the instance as COOKIE
- toDateString() : string
- Format the instance as date
- toDateTimeString() : string
- Format the instance as date and time
- toDayDateTimeString() : string
- Format the instance with day, date and time
- toFormattedDateString() : string
- Format the instance as a readable date
- toIso8601String() : string
- Format the instance as ISO8601
- toQuarter() : int|array<string|int, mixed>
- Returns the quarter
- toRfc1036String() : string
- Format the instance as RFC1036
- toRfc1123String() : string
- Format the instance as RFC1123
- toRfc2822String() : string
- Format the instance as RFC2822
- toRfc3339String() : string
- Format the instance as RFC3339
- toRfc822String() : string
- Format the instance as RFC822
- toRfc850String() : string
- Format the instance as RFC850
- toRssString() : string
- Format the instance as RSS
- toTimeString() : string
- Format the instance as time
- toUnixString() : string
- Returns a UNIX timestamp.
- toW3cString() : string
- Format the instance as W3C
- toWeek() : int
Methods
__toString()
Format the instance as a string using the set format
public
__toString() : string
Return values
stringresetToStringFormat()
Reset the format used to the default when type juggling a ChronosInterface instance to a string
public
static resetToStringFormat() : void
setToStringFormat()
Set the default format used when type juggling a ChronosInterface instance to a string
public
static setToStringFormat(string $format) : void
Parameters
- $format : string
-
The format to use in future __toString() calls.
toAtomString()
Format the instance as ATOM
public
toAtomString() : string
Return values
stringtoCookieString()
Format the instance as COOKIE
public
toCookieString() : string
Return values
stringtoDateString()
Format the instance as date
public
toDateString() : string
Return values
stringtoDateTimeString()
Format the instance as date and time
public
toDateTimeString() : string
Return values
stringtoDayDateTimeString()
Format the instance with day, date and time
public
toDayDateTimeString() : string
Return values
stringtoFormattedDateString()
Format the instance as a readable date
public
toFormattedDateString() : string
Return values
stringtoIso8601String()
Format the instance as ISO8601
public
toIso8601String() : string
Return values
stringtoQuarter()
Returns the quarter
public
toQuarter([bool $range = false ]) : int|array<string|int, mixed>
Parameters
- $range : bool = false
-
Range.
Return values
int|array<string|int, mixed> —1, 2, 3, or 4 quarter of year or array if $range true
toRfc1036String()
Format the instance as RFC1036
public
toRfc1036String() : string
Tags
Return values
stringtoRfc1123String()
Format the instance as RFC1123
public
toRfc1123String() : string
Tags
Return values
stringtoRfc2822String()
Format the instance as RFC2822
public
toRfc2822String() : string
Tags
Return values
stringtoRfc3339String()
Format the instance as RFC3339
public
toRfc3339String() : string
Tags
Return values
stringtoRfc822String()
Format the instance as RFC822
public
toRfc822String() : string
Tags
Return values
stringtoRfc850String()
Format the instance as RFC850
public
toRfc850String() : string
Tags
Return values
stringtoRssString()
Format the instance as RSS
public
toRssString() : string
Return values
stringtoTimeString()
Format the instance as time
public
toTimeString() : string
Return values
stringtoUnixString()
Returns a UNIX timestamp.
public
toUnixString() : string
Return values
string —UNIX timestamp
toW3cString()
Format the instance as W3C
public
toW3cString() : string
Return values
stringtoWeek()
public
toWeek() : int