Help with length on past broadcast

Hello all,
I need some help with the length count in the past broadcast .
When I wanne see the length from an past broadcast using the API and getting for me an strangs number back .
See here https://api.twitch.tv/kraken/videos/a599553123

"length":101,"

But the when I go the video itself see here
Video Past Broadcast Link

1.41 so I really dont know how to get the right time back I am using it in my php code see

 $plugin_title = "<img src='plugins/twitch/img/online0.gif'/>  $channelName is not streaming at the moment";
            $json  = json_decode(file_get_contents("https://api.twitch.tv/kraken/channels/uberfoolhd/videos?broadcasts=true&limit=10"));
           foreach($json->videos as $video) { 
           $plugin_body .= "<div class=\"block\">";
           $plugin_body .= "<a href=\" $video->url \"><img src=" . $video->preview . " height=\"320\" width=\"320\"></a>";
           $plugin_body .=  " $video->title ";
           $plugin_body .=  " $video->time ";
           $plugin_body .= "</div>";

Thanks for the help :slight_smile:

The “length” key’s value is in seconds, so that’s 101 seconds, which is 1m41s

1 Like

Thanks Fire for the help mate just I just starting with php so abit a noob lol

My usual time math (off the top of my head)

$hours = floor($length_in_seconds / 3600);
$left = $length_in_seconds - ($hours * 3600);
$mins = floor($left / 60);
$seconds = $left - ($mins * 60);

If that helps

1 Like

Thanks as well Barry I done it like this
echo gmdate(“H:i:s”, $video->length);

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.