检查时间戳是否为x小时? [英] Check if timestamp is x hours old?
本文介绍了检查时间戳是否为x小时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一个简单的问题,但是我找不到与这种情况完全匹配的相关主题.我发现的所有内容都涉及MySQL或日期和时间,而不仅仅是时间.
Simple question, but I couldn't find any related topics that match this exact scenario. Everything I found involved MySQL or date and time rather than just time.
我有一个时间戳记存储在一个变量中,格式为:
I have a timestamp stored in a variable in the format of:
1325960262
1325960262
生产者:
$newTimeStamp = time();
如何检查此时间戳是否早于2个小时?
我尝试过:
if (strtotime($ratesTimeStamp) <= strtotime('-2 hours')) {
echo "OLDER";
} else {
echo "not older";
}
但是没有运气.
推荐答案
拖放第一个strtotime
;该变量已采用时间戳形式:
Drop the first strtotime
; the variable is already in timestamp form:
if ($ratesTimeStamp <= strtotime('-2 hours')) {
echo "OLDER";
} else {
echo "not older";
}
这篇关于检查时间戳是否为x小时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文