$today = mktime(0,0,0,2, 9, 2011);
$today >= $r['arrival_date'] // false
9 >= date('j', $r['arrival_date']) // true
$r['arival_date'] is 1297227600 [Feb 9, 2011 07:00]
答案 0 :(得分:2)
简单:
$today = mktime(0,0,0,2, 9, 2011); // = 1297209600
和
$r['arival_date'] = 1297227600;
所以
1297227600 > 1297209600
因为
date('H',$r['arrival_date']); // 7
date('H',$today); // 0
答案 1 :(得分:1)
为了扩展并解释Andre Matos的回答,mktime(0,0,0,2,9,2011);
是00:00:00 Feb 9 2011
,基本上是2月9日的第一个瞬间,到达日期是07:00:00 Feb 9 2011
,7小时后,所以它是timestamp大于mktime创建的时间戳。
要检查时间戳是否在特定日期内,您可以通过以下几种方式检查:
//You can check by adding a day onto the timestamp for today, 24*60*60 is one days worth of seconds (86400 seconds)
if($r['arrival_date'] >= $today && $r['arrival_date'] <= $today + (24*60*60))
//Or you can mktime for tomorrow too.
$tomorrow = mktime(0,0,0,2,10,2011);
if($r['arrival_date'] >= $today && $r['arrival_date'] <= $tomorrow)
//Or you could check the way you have up there, by running it through date and checking if one is equivalent to another
//Or you could do strtotime in there somewhere, or whatever
这只是最简单的几个。基本上由于时间戳下降到第二个(特别是00:00:00 Jan 1 1970 UTC
后的秒数),你将不得不按范围检查它们。