DateTimeIso8601Normalizer::$allowedFormats

Same name in other branches
  1. 9 core/modules/serialization/src/Normalizer/DateTimeIso8601Normalizer.php \Drupal\serialization\Normalizer\DateTimeIso8601Normalizer::allowedFormats
  2. 8.9.x core/modules/serialization/src/Normalizer/DateTimeIso8601Normalizer.php \Drupal\serialization\Normalizer\DateTimeIso8601Normalizer::allowedFormats
  3. 11.x core/modules/serialization/src/Normalizer/DateTimeIso8601Normalizer.php \Drupal\serialization\Normalizer\DateTimeIso8601Normalizer::allowedFormats

Type: allowedFormats

Overrides DateTimeNormalizer::$allowedFormats

File

core/modules/serialization/src/Normalizer/DateTimeIso8601Normalizer.php, line 20

Class

DateTimeIso8601Normalizer
Converts values for the DateTimeIso8601 data type to RFC3339.

Namespace

Drupal\serialization\Normalizer

Code

protected $allowedFormats = [
    'RFC 3339' => \DateTime::RFC3339,
    'ISO 8601' => \DateTime::ISO8601,
    // @todo Remove this in https://www.drupal.org/project/drupal/issues/2958416.
    // RFC3339 only covers combined date and time representations. For date-only
    // representations, we need to use ISO 8601. There isn't a constant on the
    // \DateTime class that we can use, so we have to hardcode the format.
    // @see https://en.wikipedia.org/wiki/ISO_8601#Calendar_dates
    // @see \Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface::DATE_STORAGE_FORMAT
'date-only' => 'Y-m-d',
];

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.