Skip to content

Instantly share code, notes, and snippets.

@adrienbrault
Created August 16, 2012 08:03
Show Gist options
  • Save adrienbrault/3368211 to your computer and use it in GitHub Desktop.
Save adrienbrault/3368211 to your computer and use it in GitHub Desktop.
<?php
$dateInterval = new \DateInterval('PT35S');
$format = 'P';
if (0 < $dateInterval->y) {
$format .= '%yY';
}
if (0 < $dateInterval->m) {
$format .= '%mM';
}
// ...
$iso8601DateIntervalString = $dateInterval->format($format);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment