DateIntervalToStringTransformer
in package
implements
DataTransformerInterface
Transforms between a date string and a DateInterval object.
Tags
Interfaces, Classes, Traits and Enums
- DataTransformerInterface
- Transforms a value between different representations.
Table of Contents
- $format : mixed
- __construct() : mixed
- Transforms a \DateInterval instance to a string.
- reverseTransform() : DateInterval|null
- Transforms a date string in the configured format into a DateInterval object.
- transform() : string
- Transforms a DateInterval object into a date string with the configured format.
- isISO8601() : bool
Properties
$format
private
mixed
$format
Methods
__construct()
Transforms a \DateInterval instance to a string.
public
__construct([string $format = 'P%yY%mM%dDT%hH%iM%sS' ]) : mixed
Parameters
- $format : string = 'P%yY%mM%dDT%hH%iM%sS'
-
The date format
Tags
Return values
mixed —reverseTransform()
Transforms a date string in the configured format into a DateInterval object.
public
reverseTransform(string $value) : DateInterval|null
Parameters
- $value : string
-
An ISO 8601 or date string like date interval presentation
Tags
Return values
DateInterval|null —An instance of \DateInterval
transform()
Transforms a DateInterval object into a date string with the configured format.
public
transform(DateInterval|null $value) : string
Parameters
- $value : DateInterval|null
-
A DateInterval object
Tags
Return values
string —An ISO 8601 or relative date string like date interval presentation
isISO8601()
private
isISO8601(string $string) : bool
Parameters
- $string : string