Timestamp.php in Drupal 10
File
core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php
View source
<?php
namespace Drupal\Core\TypedData\Plugin\DataType;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\TypedData\Type\DateTimeInterface;
class Timestamp extends IntegerData implements DateTimeInterface {
protected $value;
public function getDateTime() {
if (isset($this->value)) {
return DrupalDateTime::createFromTimestamp($this->value);
}
}
public function setDateTime(DrupalDateTime $dateTime, $notify = TRUE) {
$this->value = $dateTime
->getTimestamp();
if ($notify && isset($this->parent)) {
$this->parent
->onChange($this->name);
}
}
}