function DurationIso8601::setDuration
Same name in other branches
- 9 core/lib/Drupal/Core/TypedData/Plugin/DataType/DurationIso8601.php \Drupal\Core\TypedData\Plugin\DataType\DurationIso8601::setDuration()
- 8.9.x core/lib/Drupal/Core/TypedData/Plugin/DataType/DurationIso8601.php \Drupal\Core\TypedData\Plugin\DataType\DurationIso8601::setDuration()
- 10 core/lib/Drupal/Core/TypedData/Plugin/DataType/DurationIso8601.php \Drupal\Core\TypedData\Plugin\DataType\DurationIso8601::setDuration()
Overrides DurationInterface::setDuration
File
-
core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ DurationIso8601.php, line 34
Class
- DurationIso8601
- The duration ISO8601 data type.
Namespace
Drupal\Core\TypedData\Plugin\DataTypeCode
public function setDuration(\DateInterval $duration, $notify = TRUE) {
// Generate an ISO 8601 formatted string as supported by
// DateInterval::__construct() and setValue().
$this->value = $duration->format('%rP%yY%mM%dDT%hH%mM%sS');
// 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.