mediatekformation

DateTimeToHtml5LocalDateTimeTransformer extends BaseDateTimeTransformer
in package

Tags
author

Franz Wilding franz.wilding@me.com

author

Bernhard Schussek bschussek@gmail.com

author

Fred Cox mcfedr@gmail.com

Table of Contents

HTML5_FORMAT  = 'Y-m-d\\TH:i:s'
$formats  : mixed
$inputTimezone  : mixed
$outputTimezone  : mixed
__construct()  : mixed
reverseTransform()  : DateTime|null
Transforms a local date and time string into a \DateTime.
transform()  : string
Transforms a \DateTime into a local date and time string.

Constants

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 ]) : mixed
Parameters
$inputTimezone : string|null = null

The name of the input timezone

$outputTimezone : string|null = null

The name of the output timezone

Tags
throws
InvalidArgumentException

if a timezone is not valid

Return values
mixed

reverseTransform()

Transforms a local date and time string into a \DateTime.

public reverseTransform(string $dateTimeLocal) : DateTime|null

When transforming back to DateTime the regex is slightly laxer, taking into account rules for parsing a local date and time string https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-local-date-and-time-string

Parameters
$dateTimeLocal : string

Formatted string

Tags
throws
TransformationFailedException

If the given value is not a string, if the value could not be transformed

Return values
DateTime|null

Normalized date

transform()

Transforms a \DateTime into a local date and time string.

public transform(DateTime|DateTimeInterface $dateTime) : string

According to the HTML standard, the input string of a datetime-local input is an RFC3339 date followed by 'T', followed by an RFC3339 time. https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-local-date-and-time-string

Parameters
$dateTime : DateTime|DateTimeInterface

A DateTime object

Tags
throws
TransformationFailedException

If the given value is not an instance of \DateTime or \DateTimeInterface

Return values
string

The formatted date

Search results