DateIntervalToStringTransformer
class DateIntervalToStringTransformer implements DataTransformerInterface
Transforms between a date string and a DateInterval object.
Methods
__construct(string $format = 'P%yY%mM%dDT%hH%iM%sS') Transforms a \DateInterval instance to a string. | ||
mixed | transform(mixed $value) Transforms a DateInterval object into a date string with the configured format. | |
mixed | reverseTransform(mixed $value) Transforms a date string in the configured format into a DateInterval object. |
Details
__construct(string $format = 'P%yY%mM%dDT%hH%iM%sS')
Transforms a \DateInterval instance to a string.
Parameters
string | $format | The date format |
See also
\DateInterval::format() | for supported formats |
mixed transform(mixed $value)
Transforms a DateInterval object into a date string with the configured format.
Parameters
mixed | $value | The value in the original representation |
Return Value
mixed | The value in the transformed representation |
Exceptions
UnexpectedTypeException | if the given value is not a \DateInterval instance |
mixed reverseTransform(mixed $value)
Transforms a date string in the configured format into a DateInterval object.
Parameters
mixed | $value | The value in the transformed representation |
Return Value
mixed | The value in the original representation |
Exceptions
UnexpectedTypeException | if the given value is not a string |
TransformationFailedException | if the date interval could not be parsed |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/3.4/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToStringTransformer.html