protected function DateTimeFromStringEnhancer::doUndoTransform in JSON:API Extras 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/jsonapi/FieldEnhancer/DateTimeFromStringEnhancer.php \Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer\DateTimeFromStringEnhancer::doUndoTransform()
File
- src/
Plugin/ jsonapi/ FieldEnhancer/ DateTimeFromStringEnhancer.php, line 22
Class
- DateTimeFromStringEnhancer
- Perform additional manipulations to datetime fields.
Namespace
Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancerCode
protected function doUndoTransform($data, Context $context) {
$storage_timezone = new \DateTimezone(DATETIME_STORAGE_TIMEZONE);
$date = new \DateTime($data, $storage_timezone);
$configuration = $this
->getConfiguration();
$output_timezone = new \DateTimezone(drupal_get_user_timezone());
$date
->setTimezone($output_timezone);
return $date
->format($configuration['dateTimeFormat']);
}