mediatekformation

DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer
in package

Transforms between a normalized time and a localized time string.

Tags
author

Bernhard Schussek bschussek@gmail.com

author

Florian Eckerstorfer florian@eckerstorfer.org

Table of Contents

$formats  : mixed
$inputTimezone  : mixed
$outputTimezone  : mixed
$calendar  : mixed
$dateFormat  : mixed
$pattern  : mixed
$timeFormat  : mixed
__construct()  : mixed
reverseTransform()  : DateTime|null
Transforms a localized date string/array into a normalized date.
transform()  : string
Transforms a normalized date into a localized date string/array.
getIntlDateFormatter()  : IntlDateFormatter
Returns a preconfigured IntlDateFormatter instance.
isPatternDateOnly()  : bool
Checks if the pattern contains only a date.

Properties

$formats

protected static mixed $formats = [\IntlDateFormatter::NONE, \IntlDateFormatter::FULL, \IntlDateFormatter::LONG, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT]

Methods

__construct()

public __construct([string|null $inputTimezone = null ][, string|null $outputTimezone = null ][, int|null $dateFormat = null ][, int|null $timeFormat = null ][, int $calendar = IntlDateFormatter::GREGORIAN ][, string|null $pattern = null ]) : mixed
Parameters
$inputTimezone : string|null = null

The name of the input timezone

$outputTimezone : string|null = null

The name of the output timezone

$dateFormat : int|null = null

The date format

$timeFormat : int|null = null

The time format

$calendar : int = IntlDateFormatter::GREGORIAN

One of the \IntlDateFormatter calendar constants

$pattern : string|null = null

A pattern to pass to \IntlDateFormatter

Tags
see
BaseDateTimeTransformer::formats

for available format options

throws
UnexpectedTypeException

If a format is not supported or if a timezone is not a string

Return values
mixed

reverseTransform()

Transforms a localized date string/array into a normalized date.

public reverseTransform(string|array<string|int, mixed> $value) : DateTime|null
Parameters
$value : string|array<string|int, mixed>

Localized date string/array

Tags
throws
TransformationFailedException

if the given value is not a string, if the date could not be parsed

Return values
DateTime|null

Normalized date

transform()

Transforms a normalized date into a localized date string/array.

public transform(DateTimeInterface $dateTime) : string
Parameters
$dateTime : DateTimeInterface

A DateTimeInterface object

Tags
throws
TransformationFailedException

if the given value is not a \DateTimeInterface or if the date could not be transformed

Return values
string

Localized date string

Search results