Skip to content

Instantly share code, notes, and snippets.

@AucT
Created December 27, 2020 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AucT/c2289cb82be8eccc3c66d7fd729dabb8 to your computer and use it in GitHub Desktop.
Save AucT/c2289cb82be8eccc3c66d7fd729dabb8 to your computer and use it in GitHub Desktop.
Convert php Interval (ISO8601) to seconds function, Convert php Interval (ISO8601) to minutes function
<?php
function ISO8601ToSeconds($ISO8601){
$interval = new \DateInterval($ISO8601);
return ($interval->d * 24 * 60 * 60) +
($interval->h * 60 * 60) +
($interval->i * 60) +
$interval->s;
}
function ISO8601ToMinutes($ISO8601){
$interval = new \DateInterval($ISO8601);
return ($interval->d * 24 * 60) +
($interval->h * 60) +
($interval->i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment