function TimeSpan::getDuration
Same name in other branches
- 8.9.x core/lib/Drupal/Core/TypedData/Plugin/DataType/TimeSpan.php \Drupal\Core\TypedData\Plugin\DataType\TimeSpan::getDuration()
- 10 core/lib/Drupal/Core/TypedData/Plugin/DataType/TimeSpan.php \Drupal\Core\TypedData\Plugin\DataType\TimeSpan::getDuration()
- 11.x core/lib/Drupal/Core/TypedData/Plugin/DataType/TimeSpan.php \Drupal\Core\TypedData\Plugin\DataType\TimeSpan::getDuration()
Overrides DurationInterface::getDuration
File
-
core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ TimeSpan.php, line 28
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');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.