- var_dump: documentation ( source)
<?php declare(strict_types = 1);
function toDateInterval(string $interval): DateInterval
{
if (false === ($res = DateInterval::createFromDateString($interval))) {
throw new Exception('Invalid string.');
}
return $res;
}
var_dump(toDateInterval('foobar'));