我在定义为mediumint(11)的数据库中有一个值。目前它返回3600如果我运行查询。从数据库转换时间
这个函数在这里应该将该值转换为:1小时。但是,当我运行该功能时不会。我没有任何价值。
function strTime($s) {
$d = intval($s/86400);
$s -= $d*86400;
$h = intval($s/3600);
$s -= $h*3600;
$m = intval($s/60);
$s -= $m*60;
if ($d) $str = $d . 'd ';
if ($h) $str .= $h . 'h ';
if ($m) $str .= $m . 'm ';
if ($s) $str .= $s . 's';
return $str;
}
很基本,必须是db中的值吗?调用此(的Joomla特定)
代码:
$query = "SELECT streaming_limit FROM #__cc_users WHERE user_id=".$user->id;
$db->setQuery($query);
$steaming_limit = $db->loadResult(); //returns 3600
echo strTime($streaming_limit); //returns nothing
我有一种感觉,有一个问题,在某个地方,哪来的*问题*? – 2011-12-17 21:35:02
那究竟是什么问题?你目前的输出是多少?换句话说:我们能在什么时候帮助你? ;-) – 2011-12-17 21:36:40
哎呀,添加了编辑。基本上这个函数不会像我期望的那样返回1小时,而是会得到一个空值。 – Tom 2011-12-17 21:37:14