I believe the format you're describing is the ISO 8601 date/time format. Here's how it describes intervals.
In the PHP documentation for the DateInterval
class, someone has shared an example of how you might convert a string into ISO 8601 in an object-oriented way:
http://www.php.net/manual/en/class.dateinterval.php#113415
And here is someone else's solution, using functional rather than object-oriented date methods: