View Single Post
Old 10-06-2012, 02:34 PM   PM User | #1
matt0268
New to the CF scene

 
Join Date: Dec 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
matt0268 is an unknown quantity at this point
Subtracting Time from a Time - Help

Code:
<?php
$channel = "mattbenson";
$json_file = @file_get_contents("http://api.justin.tv/api/stream/list.json?channel={$channel}", 0, null, null);
$json_array = json_decode($json_file, true);

if( array_key_exists( '0',       $json_array )
 && array_key_exists( 'channel', $json_array[0] )
 && $json_array[0]['name'] == "live_user_{$channel}" )
{
    $channelTitle = $json_array[0]['channel']['title'];
    $title        = $json_array[0]['channel']['status'];
    $viewers      = $json_array[0]['channel_count'];
    $uptime       = $json_array[0]['up_time'];
$today = date("D M j d:i:s Y");   
$uptime1 = ($today - $uptime);

    printf('Online');

printf ($uptime1);

print "<br>";
print "date <--- ";
printf ($today);
print "<br>";
print "uptime <--- ";
printf ($uptime);
}
else
{
    printf('Offline');
}

?>
It displays like this


Problem is it doesn't subtract is just displays 0

Anyhelp?

Last edited by matt0268; 10-06-2012 at 02:46 PM..
matt0268 is offline   Reply With Quote