You are here

public function DurationService::getSecondsFromDateInterval in Duration Field 8.2

Same name and namespace in other branches
  1. 3.0.x src/Service/DurationService.php \Drupal\duration_field\Service\DurationService::getSecondsFromDateInterval()

Get the number of seconds a given duration represents.

Parameters

\DateInterval $dateInterval: The DateInterval representing the duration.

Return value

int The number of seconds the interval represents.

Overrides DurationServiceInterface::getSecondsFromDateInterval

File

src/Service/DurationService.php, line 155

Class

DurationService
Provides services for the Duration Field module.

Namespace

Drupal\duration_field\Service

Code

public function getSecondsFromDateInterval(DateInterval $dateInterval) {
  return date_create('@0')
    ->add($dateInterval)
    ->getTimestamp();
}