Sf TIC Bundles

StringToTimeTransformer extends BaseDateTimeTransformer
in package

Transforms between a time string and a DateTime object.

Table of Contents

Properties

$generateFormat  : string
Format used for generating strings.

Methods

__construct()  : mixed
Transforms a \DateTime instance to a string.
reverseTransform()  : string
Transforms a DateTime object into a time string with the configured format and timezone.
transform()  : DateTime|null
Transforms a time string in the configured timezone into a DateTime object.

Properties

Methods

__construct()

Transforms a \DateTime instance to a string.

public __construct([string $inputTimezone = null ][, string $outputTimezone = null ][, string $format = 'H:i:s' ]) : mixed
Parameters
$inputTimezone : string = null

The name of the input timezone

$outputTimezone : string = null

The name of the output timezone

$format : string = 'H:i:s'

The date format

Tags
see
DateTime::format()

for supported formats

throws
UnexpectedTypeException

if a timezone is not a string

reverseTransform()

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

public reverseTransform(DateTimeInterface $dateTime) : string
Parameters
$dateTime : DateTimeInterface

A DateTimeInterface object

Tags
throws
TransformationFailedException

If the given value is not a \DateTimeInterface

Return values
string

A value as produced by PHP's date() function

transform()

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

public transform(string $value) : DateTime|null
Parameters
$value : string

A value as produced by PHP's date() function

Tags
throws
TransformationFailedException

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

Return values
DateTime|null

An instance of \DateTime


        
On this page

Search results