class Timestamp

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php \Drupal\Core\TypedData\Plugin\DataType\Timestamp

The timestamp data type.

Plugin annotation


@DataType(
  id = "timestamp",
  label = @Translation("Timestamp")
)

Hierarchy

Expanded class hierarchy of Timestamp

5 files declare their use of Timestamp
TimestampItemNormalizer.php in core/modules/serialization/src/Normalizer/TimestampItemNormalizer.php
TimestampItemNormalizer.php in core/modules/hal/src/Normalizer/TimestampItemNormalizer.php
TimestampItemNormalizerTest.php in core/modules/serialization/tests/src/Unit/Normalizer/TimestampItemNormalizerTest.php
TimestampNormalizer.php in core/modules/serialization/src/Normalizer/TimestampNormalizer.php
TimestampNormalizerTest.php in core/modules/serialization/tests/src/Unit/Normalizer/TimestampNormalizerTest.php
94 string references to 'Timestamp'
Comment::query in core/modules/comment/src/Plugin/migrate/source/d6/Comment.php
CommentSourceWithHighWaterTest::providerSource in core/modules/comment/tests/src/Kernel/Plugin/migrate/source/d6/CommentSourceWithHighWaterTest.php
core.data_types.schema.yml in core/config/schema/core.data_types.schema.yml
core/config/schema/core.data_types.schema.yml
core.data_types.schema.yml in core/config/schema/core.data_types.schema.yml
core/config/schema/core.data_types.schema.yml
core.data_types.schema.yml in core/config/schema/core.data_types.schema.yml
core/config/schema/core.data_types.schema.yml

... See full list

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/Timestamp.php, line 16

Namespace

Drupal\Core\TypedData\Plugin\DataType
View source
class Timestamp extends IntegerData implements DateTimeInterface {
  
  /**
   * The data value as a UNIX timestamp.
   *
   * @var int
   */
  protected $value;
  
  /**
   * {@inheritdoc}
   */
  public function getDateTime() {
    if (isset($this->value)) {
      return DrupalDateTime::createFromTimestamp($this->value);
    }
  }
  
  /**
   * {@inheritdoc}
   */
  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);
    }
  }

}

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