Parse ISO 8601 dates and intervals.
Install via Composer by adding the following line to the dependencies in your composer.json:
$dti = new danharper\DTI;
Passing a single ISO 8601 datetime string will provide you with an array containing that time, and the current time.
list($from, $to) = $dti->parse('2007-03-01T13:00:00Z');
Passing a single ISO 8601 duration string will substract that duration from the current time.
list($from, $to) = $dti->parse('PT2H30M'); // from is set to 2h30m before the current time
parse() with the default time to use instead of the current time:
$dti->parse('PT2H30M', new DateTime('2001-01-01'));
Passing a ISO 8601 duration string consisting of two datetimes, will give you them:
A duration string consisting of a datetime and a duration will give the datetime provided, and the datetime with the duration added to it.
And in reverse, will give you the datetime with the duration substracted, and the datetime: