public function DurationService::getDurationStringFromDateInterval in Duration Field 3.0.x
Same name and namespace in other branches
- 8.2 src/Service/DurationService.php \Drupal\duration_field\Service\DurationService::getDurationStringFromDateInterval()
Converts a PHP DateINterval object to an ISO 8601 duration string.
Parameters
\DateInterval $dateInterval: A PHP DateInterval object.
Return value
string The ISO 8601 duration string for the given \DateInterval.
Overrides DurationServiceInterface::getDurationStringFromDateInterval
File
- src/
Service/ DurationService.php, line 91
Class
- DurationService
- Provides services for the Duration Field module.
Namespace
Drupal\duration_field\ServiceCode
public function getDurationStringFromDateInterval(DateInterval $dateInterval) {
return $this
->convertDateArrayToDurationString([
'y' => $dateInterval
->format('%y'),
'm' => $dateInterval
->format('%m'),
'd' => $dateInterval
->format('%d'),
'h' => $dateInterval
->format('%h'),
'i' => $dateInterval
->format('%i'),
's' => $dateInterval
->format('%s'),
]);
}