PHP时间差异

时间:2011-07-19 14:32:06

标签: php time minute


$myTime = "1311059513";
$now = time();
$timeDiff = ($now - $myTime)/60;

我正在尝试从$myTime中减去$now以获得差异并除以60以获得分钟差异。 出于某种原因,我不会在$timeDiff中得到分钟。

1 个答案:

答案 0 :(得分:1)

开:PHP 5.3.2-1ubuntu4.7 with Suhosin-Patch (cli) (built: Jan 12 2011 18:36:55)

我明白了:

$myTime = "1311059513";
$now = time();
$timeDiff = ($now - $myTime)/60;
echo $timeDiff; // 443.78333333333

有什么问题?

1311059513 corresponds to 2011-07-19T02:11:53-05:00
ran it at 2011-07-19T09:35:40-05:00

09:35:40 - 02:11:53 = 7hrs 23min 57s = 443min 57s = 443.7833...