protected function DateTimeFromStringEnhancer::doTransform 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::doTransform()
File
- src/
Plugin/ jsonapi/ FieldEnhancer/ DateTimeFromStringEnhancer.php, line 37
Class
- DateTimeFromStringEnhancer
- Perform additional manipulations to datetime fields.
Namespace
Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancerCode
protected function doTransform($data, Context $context) {
$date = new \DateTime($data);
// Adjust the date for storage.
$storage_timezone = new \DateTimezone(DATETIME_STORAGE_TIMEZONE);
$date
->setTimezone($storage_timezone);
return $date
->format(DATETIME_DATETIME_STORAGE_FORMAT);
}