DateTimeToStringTransformer

class DateTimeToStringTransformer extends BaseDateTimeTransformer

Transforms between a date string and a DateTime object.

Methods

__construct(string $inputTimezone = null, string $outputTimezone = null, string $format = 'Y-m-d H:i:s', bool $parseUsingPipe = true)

Transforms a \DateTime instance to a string.

mixed transform(DateTimeInterface $dateTime)

Transforms a DateTime object into a date string with the configured format and timezone.

mixed reverseTransform(mixed $value)

Transforms a date string in the configured timezone into a DateTime object.

Details

__construct(string $inputTimezone = null, string $outputTimezone = null, string $format = 'Y-m-d H:i:s', bool $parseUsingPipe = true)

Transforms a \DateTime instance to a string.

Parameters

string $inputTimezone The name of the input timezone
string $outputTimezone The name of the output timezone
string $format The date format
bool $parseUsingPipe Whether to parse by appending a pipe "|" to the parse format

Exceptions

UnexpectedTypeException if a timezone is not a string

See also

\DateTime::format() for supported formats

mixed transform(DateTimeInterface $dateTime)

Transforms a DateTime object into a date string with the configured format and timezone.

Parameters

DateTimeInterface $dateTime A DateTimeInterface object

Return Value

mixed The value in the transformed representation

Exceptions

TransformationFailedException If the given value is not a \DateTimeInterface

mixed reverseTransform(mixed $value)

Transforms a date string in the configured timezone into a DateTime object.

Parameters

mixed $value The value in the transformed representation

Return Value

mixed The value in the original representation

Exceptions

TransformationFailedException If the given value is not a string, or could not be transformed
doc_Symfony
2016-10-28 06:13:11
Comments
Leave a Comment

Please login to continue.