title: Convert youtube Api v3 video duration in php
body: <p>how do i convert PT2H34M25S to 2:34:25</p>
  
  <p>I searched and used this code. I'm new to regex can someone explain this ? and help me with my issue</p>
  
  <pre><code>function covtime($youtube_time){
          preg_match_all('/(\d+)/',$youtube_time,$parts);
          $hours = floor($parts[0][0]/60);
          $minutes = $parts[0][0]%60;
          $seconds = $parts[0][1];
          if($hours != 0)
              return $hours.':'.$minutes.':'.$seconds;
          else
              return $minutes.':'.$seconds;
      }   
  </code></pre>
  
  <p>but this code only give me HH:MM </p>
  
  <p>so dumb found the solution : </p>
  
  <pre><code>   function covtime($youtube_time){
              preg_match_all('/(\d+)/',$youtube_time,$parts);
              $hours = $parts[0][0];
              $minutes = $parts[0][1];
              $seconds = $parts[0][2];
              if($seconds != 0)
                  return $hours.':'.$minutes.':'.$seconds;
              else
                  return $hours.':'.$minutes;
          }
  </code></pre>