DateFormatter
Wrapper for dealing with ICU-based (php-intl) date formatting see https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax
Table of Contents
Methods
- convertPhpFormatToLuxon() : string
- format() : string
- Formats any given input ($date) into a localized, formatted result
- strftime() : string
- Locale-formatted strftime using IntlDateFormatter (PHP 8.1 compatible) This provides a cross-platform alternative to strftime() for when it will be removed from PHP.
Methods
convertPhpFormatToLuxon()
public
convertPhpFormatToLuxon(string $phpFormat) : string
Parameters
- $phpFormat : string
Return values
stringformat()
Formats any given input ($date) into a localized, formatted result
public
format(mixed $date, string|int $format, string|Locale $locale) : string
Parameters
- $date : mixed
-
could be a DateTime object, a string or a number (Unix Timestamp)
- $format : string|int
-
the pattern, as defined by the ICU - see https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax
- $locale : string|Locale
-
the locale to be used, e.g. "nl-NL"
Return values
string —the formatted output, such as "Tuesday at 12:40:20"
strftime()
Locale-formatted strftime using IntlDateFormatter (PHP 8.1 compatible) This provides a cross-platform alternative to strftime() for when it will be removed from PHP.
public
strftime(string $format, int|string|DateTimeInterface|null $timestamp[, string|Locale|null $locale = null ][, mixed $useUtcTimeZone = false ]) : string
Note that output can be slightly different between libc sprintf and this function as it is using ICU.
Original author BohwaZ https://bohwaz.net/ Adapted from https://github.com/alphp/strftime MIT licensed
Parameters
- $format : string
- $timestamp : int|string|DateTimeInterface|null
- $locale : string|Locale|null = null
- $useUtcTimeZone : mixed = false