You are here

public function DateTimeIso8601::setDateTime in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/TypedData/Plugin/DataType/DateTimeIso8601.php \Drupal\Core\TypedData\Plugin\DataType\DateTimeIso8601::setDateTime()

Sets the date time object.

Parameters

\Drupal\Core\Datetime\DrupalDateTime $dateTime: An instance of a date time object.

Overrides DateTimeInterface::setDateTime

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/DateTimeIso8601.php, line 40

Class

DateTimeIso8601
A data type for ISO 8601 date strings.

Namespace

Drupal\Core\TypedData\Plugin\DataType

Code

public function setDateTime(DrupalDateTime $dateTime, $notify = TRUE) {
  $this->value = $dateTime
    ->format('c');

  // Notify the parent of any changes.
  if ($notify && isset($this->parent)) {
    $this->parent
      ->onChange($this->name);
  }
}