public function DateTimeIso8601::getDateTime in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/TypedData/Plugin/DataType/DateTimeIso8601.php \Drupal\Core\TypedData\Plugin\DataType\DateTimeIso8601::getDateTime()
Returns the date time object.
Return value
\Drupal\Core\Datetime\DrupalDateTime|null A date object or NULL if there is no date.
Overrides DateTimeInterface::getDateTime
File
- core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ DateTimeIso8601.php, line 23
Class
- DateTimeIso8601
- A data type for ISO 8601 date strings.
Namespace
Drupal\Core\TypedData\Plugin\DataTypeCode
public function getDateTime() {
if ($this->value) {
if (is_array($this->value)) {
// Data of this type must always be stored in UTC.
$datetime = DrupalDateTime::createFromArray($this->value, 'UTC');
}
else {
// Data of this type must always be stored in UTC.
$datetime = new DrupalDateTime($this->value, 'UTC');
}
return $datetime;
}
}