mediatekformation

DateIntervalToStringTransformer
in package
implements DataTransformerInterface

Transforms between a date string and a DateInterval object.

Tags
author

Steffen Roßkamp steffen.rosskamp@gimmickmedia.de

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

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
see
DateInterval::format()

for supported formats

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
throws
UnexpectedTypeException

if the given value is not a string

throws
TransformationFailedException

if the date interval could not be parsed

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
throws
UnexpectedTypeException

if the given value is not a \DateInterval instance

Return values
string

An ISO 8601 or relative date string like date interval presentation

Search results