‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Localization\DateFormatter Class Reference

Public Member Functions

string format (mixed $date, string|int $format, string|Locale $locale)
 strftime (string $format, int|string|\DateTimeInterface|null $timestamp, string|Locale|null $locale=null, $useUtcTimeZone=false)

Detailed Description

Wrapper for dealing with ICU-based (php-intl) date formatting see https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax

Definition at line 26 of file DateFormatter.php.

Member Function Documentation

◆ format()

string TYPO3\CMS\Core\Localization\DateFormatter::format ( mixed  $date,
string|int  $format,
string|Locale  $locale 

Formats any given input ($date) into a localized, formatted result

mixed$date‪could be a DateTime object, a string or a number (Unix Timestamp)
string | int$format‪the pattern, as defined by the ICU - see https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax
string | Locale$locale‪the locale to be used, e.g. "nl-NL"
‪string the formatted output, such as "Tuesday at 12:40:20"

Definition at line 36 of file DateFormatter.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger().

◆ strftime()

TYPO3\CMS\Core\Localization\DateFormatter::strftime ( string  $format,
int|string|\DateTimeInterface|null  $timestamp,
string|Locale|null  $locale = null,
  $useUtcTimeZone = false 

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. 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

Definition at line 75 of file DateFormatter.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger().