Fr3nch13/CakePHP Utilities

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
string

resetToStringFormat()

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
string

toCookieString()

Format the instance as COOKIE

public toCookieString() : string
Return values
string

toDateString()

Format the instance as date

public toDateString() : string
Return values
string

toDateTimeString()

Format the instance as date and time

public toDateTimeString() : string
Return values
string

toDayDateTimeString()

Format the instance with day, date and time

public toDayDateTimeString() : string
Return values
string

toFormattedDateString()

Format the instance as a readable date

public toFormattedDateString() : string
Return values
string

toIso8601String()

Format the instance as ISO8601

public toIso8601String() : string
Return values
string

toQuarter()

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

toRssString()

Format the instance as RSS

public toRssString() : string
Return values
string

toTimeString()

Format the instance as time

public toTimeString() : string
Return values
string

toUnixString()

Returns a UNIX timestamp.

public toUnixString() : string
Return values
string

UNIX timestamp

toW3cString()

Format the instance as W3C

public toW3cString() : string
Return values
string

        
On this page

Search results