FormatterDateTimeToJson
in package
implements
FormatterInterface
Formatter DateTime to Json
This formatter converts date/time string values assumed to be in server timezone to UTC time and formats to the JSON standard 'Y-m-d\TH:i:s.000\Z'.
For values that should always be displayed as is, we should not use this formatter but instead use only the 'date' valitator. For exmaple we use this formatter on 'survey.dateCreated' but not on 'survey.expires' or 'survey.startDate' because we want to display and edit the values of 'survey.expires' or 'survey.startDate' using the server timezone not the local timezone.
Table of Contents
Interfaces
Methods
- format() : mixed|null
- Cast UTC datetime string to JSON datetime string
- apply() : string|null
- Cast UTC datetime string to JSON datetime string
- dateFormat() : string|null
- Date format
- revert() : string|null
- Cast JSON datetime string to UTC datetime string
Methods
format()
Cast UTC datetime string to JSON datetime string
public
format(mixed|null $value[, array<string|int, mixed> $config = [] ][, array<string|int, mixed> $options = [] ]) : mixed|null
Parameters
- $value : mixed|null
- $config : array<string|int, mixed> = []
- $options : array<string|int, mixed> = []
Tags
Return values
mixed|nullapply()
Cast UTC datetime string to JSON datetime string
protected
apply(mixed|null $value, array<string|int, mixed> $config) : string|null
Parameters
- $value : mixed|null
- $config : array<string|int, mixed>
Tags
Return values
string|nulldateFormat()
Date format
protected
dateFormat(string|null $value, string $inputTimeZone, string $outputTimezone, string $outputFormat, array<string|int, mixed> $config) : string|null
Parameters
- $value : string|null
- $inputTimeZone : string
- $outputTimezone : string
- $outputFormat : string
- $config : array<string|int, mixed>
Return values
string|nullrevert()
Cast JSON datetime string to UTC datetime string
protected
revert(mixed|null $value, array<string|int, mixed> $config) : string|null
Parameters
- $value : mixed|null
- $config : array<string|int, mixed>