特定时间与当前时间之间的时差 [英] Difference between specific time and current time

查看:61
本文介绍了特定时间与当前时间之间的时差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我有一段时间使用UNIX格式.我需要找到特定时间与当前时间之间的时差.如果相差5分钟.做点什么.

Well i have a time in UNIX format. i need to find the difference between a specific time and current time. if difference is 5 minutes. do something.

$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
}

如何找到分钟差以及如何获取当前时间?

EDIT : How to find the difference in minutes and how to get currenttime?

推荐答案

尝试首先使用 date()记录分钟,然后像进行比较

Try to get minute first using date() then compare like

$sp_time = 1400325952;//Specific time
$currentTime = time(); // current time 
$difference = $currentTime - $sp_time;
if(date('i',$difference) >= '5') {
    //DO SOME STUFF
}

这篇关于特定时间与当前时间之间的时差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆