具体时间和当前时间的差异
问题描述:
那么我有一个UNIX格式的时间。我需要找出特定时间和当前时间之间的差异。如果差异是5分钟。做一点事。具体时间和当前时间的差异
$sp_time = 1400325952;//Specific time
$currentTime = //current time in UNIX format
$difference = $currentTime - $sp_time;
if($difference >= 5)//if difference is less than or equal to 5minutes
{
//DO SOME STUFF
}
编辑:如何在几分钟内找到差异以及如何获得当前时间?
答
尝试先获取分钟使用date()
则比较喜欢
$sp_time = 1400325952;//Specific time
$currentTime = time(); // current time
$difference = $currentTime - $sp_time;
if(date('i',$difference) >= '5') {
//DO SOME STUFF
}
答
不知道这是你在找什么...
$sp_time = 1400325952;//Specific time
$currentTime = time(); // current time
$diff = abs($currentTime - $sp_time);
$mins = round($diff/60);
if ($mins <= 5) {
echo "difference is less than or equal to 5minutes: $mins";
}
请告诉我你的问题就在这里?描述你的问题/错误。 – 2015-02-10 05:37:56