You are here

protected function DateTimeEnhancer::doTransform in JSON:API Extras 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/jsonapi/FieldEnhancer/DateTimeEnhancer.php \Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer\DateTimeEnhancer::doTransform()

File

src/Plugin/jsonapi/FieldEnhancer/DateTimeEnhancer.php, line 38

Class

DateTimeEnhancer
Perform additional manipulations to timestamp fields.

Namespace

Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer

Code

protected function doTransform($data, Context $context) {
  $date = new \DateTime($data);
  return (int) $date
    ->format('U');
}