You are here

public function DateTimeEnhancer::prepareForInput in JSON:API Extras 8

Apply the initial transformations to the input value of a single field.

Parameters

mixed $value: The value to be processed so it can be used as an input.

Return value

mixed The value after being post precessed.

Overrides DateTimeEnhancerBase::prepareForInput

File

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

Class

DateTimeEnhancer
Perform additional manipulations to timestamp fields.

Namespace

Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer

Code

public function prepareForInput($value) {
  $date = new \DateTime($value);
  return (int) $date
    ->format('U');
}