如何比较php中的2个时间戳 [英] How to compare 2 timestamp in php

查看:719
本文介绍了如何比较php中的2个时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我需要时间戳比较的帮助,其中我有时间戳time2 = 2013/04 / 06T13:24:00Z我想比较这与当前时间戳。我需要这个比较来检查时间是否少于10分钟。



if((time1-time2)< 600)

{

echo''有效时间'';

//做一些东西

}

else

{

echo''time expired'';

}



这里time1将是当前时间戳,time2将是我的给定时间戳,我将600作为10分钟。



有没有办法比较这种格式的时间戳.. 。如果你知道,请建议



谢谢。

Hi friends,

I need a help on timestamp compare wherein I have a timestamp time2=2013/04/06T13:24:00Z and I want to compare this with current timestamp. I need this comparision to check if the time is less then 10 minutes.

if ((time1-time2)<600)
{
echo ''valid time'';
//do some stuff
}
else
{
echo ''time expired'';
}

Here time1 will be current timestamp and time2 will be my given timestamp and I am taking 600 as 10 minutes.

Is there any way to compare timestamp for this type of format...Please suggest if you know

Thankyou.

推荐答案

相当不错的文章 - 比较PHP中的日期 [ ^ ]。
Pretty good article - Comparing Dates in PHP[^].


这篇关于如何比较php中的2个时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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