DateTimeToHtml5LocalDateTimeTransformer
extends BaseDateTimeTransformer
in package
Tags
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
HTML5_FORMAT
public
mixed
HTML5_FORMAT
= 'Y-m-d\\TH:i:s'
Properties
$formats
protected
static mixed
$formats
= [\IntlDateFormatter::NONE, \IntlDateFormatter::FULL, \IntlDateFormatter::LONG, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT]
$inputTimezone
protected
mixed
$inputTimezone
$outputTimezone
protected
mixed
$outputTimezone
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
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
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
Return values
string —The formatted date