$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]
Simple:
$today = mktime(0,0,0,2, 9, 2011); // = 1297209600
and
$r['arival_date'] = 1297227600;
so
1297227600 > 1297209600
because
date('H',$r['arrival_date']); // 7
date('H',$today); // 0
To expand and explain upon Andre Matos' answer, mktime(0,0,0,2,9,2011);
is 00:00:00 Feb 9 2011
, basically the first instant of Feb 9, and the Arrival Date is 07:00:00 Feb 9 2011
, 7 hours later, so it's timestamp is greater than the one created by mktime.
To check whether or not a timestamp falls within a specific day, you can check in a few different ways:
//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
That's just a couple of the easiest. Basically since timestamps are down to the second (specifically seconds since 00:00:00 Jan 1 1970 UTC
), you're gonna have to check them by range.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.