<?php function dateIntervalToSeconds($dateInterval) { $reference = new DateTimeImmutable; $endTime = $reference->add($dateInterval); return $endTime->getTimestamp() - $reference->getTimestamp(); } $duration = '1h1m1s'; $interval = new DateInterval('PT' . strtoupper($duration)); echo $duration, ' is ', dateIntervalToSeconds($interval), ' seconds';
You have javascript disabled. You will not be able to edit any code.