public function TimeSpan::getDuration in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/TypedData/Plugin/DataType/TimeSpan.php \Drupal\Core\TypedData\Plugin\DataType\TimeSpan::getDuration()
Returns the duration.
Return value
\DateInterval|null A DateInterval object or NULL if there is no duration.
Throws
\Exception
Overrides DurationInterface::getDuration
File
- core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ TimeSpan.php, line 33 - Contains \Drupal\Core\TypedData\Plugin\DataType\TimeSpan.
Class
- TimeSpan
- The time span data type represents durations as number of seconds.
Namespace
Drupal\Core\TypedData\Plugin\DataTypeCode
public function getDuration() {
if ($this->value) {
// Keep the duration in seconds as there is generally no valid way to
// convert it to days, months or years.
return new \DateInterval('PT' . $this->value . 'S');
}
}