Convert SQL column from seconds to iTunes compatible time format for podcast using PHP
I have an SQL table containing MP3 metadata (not the actual MP3 files) entered using a script from the lib_getid3 project which reads the data from an MP3s metadata and automatically imports that into an SQL database, so it has columns (among others) containing "title", "author", "fileformat", and, annoyingly, "playtime_seconds".

I can output the data as a readable podcast using the following code, though it isn't iTunes compatible because of the "length" and "duration" tags :

    <item>
      <title><?=($test); ?></title>
      <link>http://website/<?=basename(rtrim($row['filename'], '/')); ?></link>

      <itunes:author><?=$row['artist']; ?></itunes:author><enclosure url="http://website/<?=basename(rtrim($row['filename'], '/')); ?>" length="<?=$row['playtime_seconds']?>" type="audio/mpeg" />
     <itunes:category>podcast</itunes:category> 
      <pubDate><?=date('D, j M Y H:i:s O',$row{'LastModified'}) ?></pubDate>


    <itunes:keywords>Podcast</itunes:keywords>
    <itunes:duration><?=$row['playtime_seconds']; ?></itunes:duration>
    <guid isPermaLink="false"><?= substr($test, 0, strrpos($test, '.')); ?><?=$row['filesize'];?></guid>
      
    </item>

But the duration being in seconds throws up an invalid response when validated. It should be in minutes and seconds and must be a positive integer.
I've tried a couple of suggestions on here already, for example:

        $seconds = $row['playtime_seconds'] % 60;
        $time = ($row['playtime_seconds'] - $seconds) / 60;
        $minutes = $row['playtime_seconds'] % 60;
        $hours = ($row['playtime_seconds'] - $minutes) / 60;

But the output is still not valid according to iTunes. 
I can't add an extra row in the SQL table itself to store a converted number, as it will be removed each time the import script is run (and I'd rather not break the script rewritting it), so if it can be done in PHP then that would be great. 
Convert SQL column from seconds to iTunes compatible time format for podcast using PHP
===

I have an SQL table containing MP3 metadata (not the actual MP3 files) entered using a script from the lib_getid3 project which reads the data from an MP3s metadata and automatically imports that into an SQL database, so it has columns (among others) containing "title", "author", "fileformat", and, annoyingly, "playtime_seconds".

I can output the data as a readable podcast using the following code, though it isn't iTunes compatible because of the "length" and "duration" tags :

    <item>
      <title><?=($test); ?></title>
      <link>http://website/<?=basename(rtrim($row['filename'], '/')); ?></link>

      <itunes:author><?=$row['artist']; ?></itunes:author><enclosure url="http://website/<?=basename(rtrim($row['filename'], '/')); ?>" length="<?=$row['playtime_seconds']?>" type="audio/mpeg" />
     <itunes:category>podcast</itunes:category> 
      <pubDate><?=date('D, j M Y H:i:s O',$row{'LastModified'}) ?></pubDate>


    <itunes:keywords>Podcast</itunes:keywords>
    <itunes:duration><?=$row['playtime_seconds']; ?></itunes:duration>
    <guid isPermaLink="false"><?= substr($test, 0, strrpos($test, '.')); ?><?=$row['filesize'];?></guid>
      
    </item>

But the duration being in seconds throws up an invalid response when validated. It should be in minutes and seconds and must be a positive integer.
I've tried a couple of suggestions on here already, for example:

        $seconds = $row['playtime_seconds'] % 60;
        $time = ($row['playtime_seconds'] - $seconds) / 60;
        $minutes = $row['playtime_seconds'] % 60;
        $hours = ($row['playtime_seconds'] - $minutes) / 60;

But the output is still not valid according to iTunes. 
I can't add an extra row in the SQL table itself to store a converted number, as it will be removed each time the import script is run (and I'd rather not break the script rewritting it), so if it can be done in PHP then that would be great. 