[solved] Problem with && in UDT
Posted: Thu May 13, 2010 9:35 am
I'm having difficulty with one of my UDT's. I use the tag to compare 2 unix timestamps, and return XX minutes ago, or XX seconds ago. I got it working using simple > rules, but I'd quite like to include && so I can say "1 hour ago" rather than "1 hours ago".
Any suggestions?
Code: Select all
if($params['time']){
$postedTime = $params['time'];
$timediff = time() - $postedTime;
switch (TRUE)
{
case ($timediff > 60):
return round($timediff / 60) . ' minutes ago';
break;
case ($timediff >= 3600 && < 7200):
return '1 hour ago';
break;
case ($timediff >= 7200):
return round($timediff / 3600) . ' hours ago';
break;
case ($timediff >= 86400 && < 172800):
return '1 day ago';
break;
case ($timediff >= 172800):
return round($timediff / 86400) . ' days ago';
break;
default:
return $timediff . ' seconds ago';
}
}