如何从当前时间到给定时间分钟获得时差

时间:2014-08-07 12:20:57

标签: php

我希望从当前Times计算的给定时间与UNIX格式之间得到时间差。

我的代码没有给我正确答案。

我的PHP代码:

$my_time = 1407410382;
$time_diff = strtotime(strftime("%F") . ' ' .$my_time) - time();

1 个答案:

答案 0 :(得分:0)

尝试:

$then = 1407410382;

//Get the current timestamp.
$now = time();

//Calculate the difference.
$difference = $now - $then;

//Convert seconds into minutes.
$minutes = floor($difference / 60);

echo $minutes;