function TimestampItem::generateSampleValue
Same name in other branches
- 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php \Drupal\Core\Field\Plugin\Field\FieldType\TimestampItem::generateSampleValue()
- 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php \Drupal\Core\Field\Plugin\Field\FieldType\TimestampItem::generateSampleValue()
- 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php \Drupal\Core\Field\Plugin\Field\FieldType\TimestampItem::generateSampleValue()
Overrides FieldItemBase::generateSampleValue
File
-
core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldType/ TimestampItem.php, line 59
Class
- TimestampItem
- Defines the 'timestamp' entity field type.
Namespace
Drupal\Core\Field\Plugin\Field\FieldTypeCode
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
// Pick a random timestamp in the past year.
$timestamp = \Drupal::time()->getRequestTime() - mt_rand(0, 86400 * 365);
$values['value'] = $timestamp;
return $values;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.