Quote (KIDRitch @ Sun, Oct 5 2008, 02:37am)
So how do you convert the lastaction to hours/ minutes / seconds?
Code
<lastaction>1223188360</lastaction>
Code
$lastaction = (int)$data->lastaction;
$time1 = time() - $lastaction;
$lastplayed = sec2hms($time1);
ImageTTFText ($image, 8, 0, 222, 82, $plasmictext, $font, $lastplayed);
function sec2hms ($sec, $padHours = false)
{
$days = intval(intval($sec) / 86400);
$hours = intval(($sec / 3600) % 24);
$minutes = intval(($sec / 60) % 60);
if ($days > 0) {
$hms = $days. ' days, ';
$hms .= ($padHours)
? str_pad($hours, 2, "0", STR_PAD_LEFT). ' hours ago'
: $hours. ' hours ago';
} else {
$hms = "";
$hms .= ($padHours)
? str_pad($hours, 2, "0", STR_PAD_LEFT). ' hours, '
: $hours. ' hours, ';
$hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ' minutes ago';
}
return $hms;
}
There ya go.