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
$generateFormat
Format used for generating strings.
private
string
$generateFormat
= 'H:i:s'
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
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
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
Return values
DateTime|null —An instance of \DateTime