function TimeStampItemNormalizerTrait::processNormalizedValues
Processes normalized timestamp values to add a formatted date and format.
Parameters
array $normalized: The normalized field data to process.
Return value
array The processed data.
File
-
core/
modules/ serialization/ src/ Normalizer/ TimeStampItemNormalizerTrait.php, line 44
Class
- TimeStampItemNormalizerTrait
- A trait for TimestampItem normalization functionality.
Namespace
Drupal\serialization\NormalizerCode
protected function processNormalizedValues(array $normalized) {
// Use a RFC 3339 timestamp with the time zone set to UTC to replace the
// timestamp value.
$date = new \DateTime();
$date->setTimestamp($normalized['value']);
$date->setTimezone(new \DateTimeZone('UTC'));
$normalized['value'] = $date->format(\DateTime::RFC3339);
// 'format' is not a property on TimestampItem fields. This is present to
// assist consumers of this data.
$normalized['format'] = \DateTime::RFC3339;
return $normalized;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.