To recover the interval specification string:
<?php
function get_interval_spec(DateTime $alpha, DateTime $omega)
{
$intvl = $alpha->diff($omega);
$date = NULL;
if ($intvl->y) $date .= $intvl->y . 'Y';
if ($intvl->m) $date .= $intvl->m . 'M';
if ($intvl->d) $date .= $intvl->d . 'D';
$time = NULL;
if ($intvl->h) $time .= $intvl->h . 'H';
if ($intvl->i) $time .= $intvl->i . 'M';
if ($intvl->s) $time .= $intvl->s . 'S';
if ($time) $time = 'T' . $time;
$text ='P' . $date . $time;
if ($text == 'P') return 'PT0S';
return $text;
}