[英]Difference between specific time and current time
好吧,我有一段時間使用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";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.