Trait FormattingTrait
Provides string formatting methods for datetime instances.
Expects implementing classes to define static::$toStringFormat
Method Summary
-
__toString() public
Returns a formatted string specified by
setToStringFormat()
or the defaultDEFAULT_TO_STRING_FORMAT
format. -
resetToStringFormat() public static
Resets the __toString() format to
DEFAULT_TO_STRING_FORMAT
. -
setToStringFormat() public static
Sets the __toString() format.
-
toAtomString() public
Format the instance as ATOM
-
toCookieString() public
Format the instance as COOKIE
-
toDateString() public
Format the instance as date
-
toDateTimeString() public
Format the instance as date and time
-
toDayDateTimeString() public
Format the instance with day, date and time
-
toFormattedDateString() public
Format the instance as a readable date
-
toIso8601String() public
Format the instance as ISO8601
-
toQuarter() public
Returns the quarter
-
toRfc1036String() public
Format the instance as RFC1036
-
toRfc1123String() public
Format the instance as RFC1123
-
toRfc2822String() public
Format the instance as RFC2822
-
toRfc3339String() public
Format the instance as RFC3339
-
toRfc822String() public
Format the instance as RFC822
-
toRfc850String() public
Format the instance as RFC850
-
toRssString() public
Format the instance as RSS
-
toTimeString() public
Format the instance as time
-
toUnixString() public
Returns a UNIX timestamp.
-
toW3cString() public
Format the instance as W3C
-
toWeek() public
Returns ISO 8601 week number of year, weeks starting on Monday
Method Detail
__toString() ¶ public
__toString(): string
Returns a formatted string specified by setToStringFormat()
or the default DEFAULT_TO_STRING_FORMAT
format.
Returns
string
resetToStringFormat() ¶ public static
resetToStringFormat(): void
Resets the __toString() format to DEFAULT_TO_STRING_FORMAT
.
Returns
void
setToStringFormat() ¶ public static
setToStringFormat(string $format): void
Sets the __toString() format.
Parameters
-
string
$format See
format()
for accepted specifiers.
Returns
void
toDateTimeString() ¶ public
toDateTimeString(): string
Format the instance as date and time
Returns
string
toDayDateTimeString() ¶ public
toDayDateTimeString(): string
Format the instance with day, date and time
Returns
string
toFormattedDateString() ¶ public
toFormattedDateString(): string
Format the instance as a readable date
Returns
string
toQuarter() ¶ public
toQuarter(bool $range = false): array|int
Returns the quarter
Parameters
-
bool
$range optional Range.
Returns
array|int
toRfc1036String() ¶ public
toRfc1036String(): string
Format the instance as RFC1036
Returns
string
Links
toRfc1123String() ¶ public
toRfc1123String(): string
Format the instance as RFC1123
Returns
string
Links
toRfc2822String() ¶ public
toRfc2822String(): string
Format the instance as RFC2822
Returns
string
Links
toRfc3339String() ¶ public
toRfc3339String(): string
Format the instance as RFC3339
Returns
string
Links
toRfc822String() ¶ public
toRfc822String(): string
Format the instance as RFC822
Returns
string
Links
toRfc850String() ¶ public
toRfc850String(): string
Format the instance as RFC850
Returns
string
Links
toWeek() ¶ public
toWeek(): int
Returns ISO 8601 week number of year, weeks starting on Monday
Returns
int