我正在使用php设计一个像时间戳差异函数的facebook,如下所示:
function time_parser($time)
{
if(!is_numeric($time))
{
$time = strtotime($time);
if(!is_numeric($time))
{
return "";
}
}
$difference = time() - $time;
$periods = array("sec","min","hour","day","week","month","year");
$lengths = array("60","60","24","7","4.35","12","10");
if($difference > 0)
{
$ending = "ago";
}
else
{
$difference = -$difference;
$ending = "to go";
}
for($j=0; $difference>=$lengths[$j] && $j<7;$j++)
{
$difference /= $lengths[$j];
}
$difference = round($difference);
if($difference!=1)
{
$periods[$j].="s";
}
$text = "$difference $periods[$j] $ending";
return $text;
}
现在的问题是,它会在一小时前的几小时内得出结果。怎么了 ?它取决于我的电脑的时区设置吗?
答案 0 :(得分:0)