我有一个像这个的PHP服务器时间,我需要把这个时间转换成这样的左下角计数
6 hours lefts
7 hours lefts
答案 0 :(得分:3)
$time_left = floor((time() - strtotime($server_time)) / 3600);
echo $time_left.' hours left';
答案 1 :(得分:1)
代码:
$target = strtotime($server_time); // 1 - note: $server_time should be your
// string, whereever you get that from
$now = time(); // 2
$left = $target - $now; // 3
echo floor($left/3600).' hours left';// 4