3 namespace Drupal\Core\TypedData\Plugin\DataType;
5 use Drupal\Core\Datetime\DrupalDateTime;
6 use Drupal\Core\TypedData\Type\DateTimeInterface;
9 * The timestamp data type.
13 * label = @Translation("Timestamp")
16 class Timestamp extends IntegerData implements DateTimeInterface {
19 * The data value as a UNIX timestamp.
28 public function getDateTime() {
30 return DrupalDateTime::createFromTimestamp($this->value);
37 public function setDateTime(DrupalDateTime $dateTime, $notify = TRUE) {
38 $this->value = $dateTime->getTimestamp();
39 // Notify the parent of any changes.
40 if ($notify && isset($this->parent)) {
41 $this->parent->onChange($this->name);