You are here

public function Timestamp::setDateTime in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php \Drupal\Core\TypedData\Plugin\DataType\Timestamp::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/Timestamp.php, line 37

Class

Timestamp
The timestamp data type.

Namespace

Drupal\Core\TypedData\Plugin\DataType

Code

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

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