class DateTimeToHtml5LocalDateTimeTransformer extends BaseDateTimeTransformer

Constants

HTML5_FORMAT

Properties

static protected $formats from BaseDateTimeTransformer
protected $inputTimezone from BaseDateTimeTransformer
protected $outputTimezone from BaseDateTimeTransformer

Methods

__construct(string $inputTimezone = null, string $outputTimezone = null)

No description

mixed
transform(DateTime|DateTimeInterface $dateTime)

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

mixed
reverseTransform(string $dateTimeLocal)

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

Details

__construct(string $inputTimezone = null, string $outputTimezone = null)

Parameters

string $inputTimezone The name of the input timezone
string $outputTimezone The name of the output timezone

Exceptions

UnexpectedTypeException if a timezone is not a string
InvalidArgumentException if a timezone is not valid

at line 39
mixed transform(DateTime|DateTimeInterface $dateTime)

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

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

Parameters

DateTime|DateTimeInterface $dateTime A DateTime object

Return Value

mixed The value in the transformed representation

Exceptions

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

at line 74
mixed reverseTransform(string $dateTimeLocal)

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

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

string $dateTimeLocal Formatted string

Return Value

mixed The value in the original representation

Exceptions

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