2011-02-02 19 views
0
$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

'var_dump($ r ['arrival_date'])'は何を表示しますか? – dnagirl

答えて

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

Andre Matosの答えをmktime(0,0,0,2,9,2011);と解釈すると、基本的に2月9日の最初の瞬間であり、到着日は7時間後の07:00:00 Feb 9 2011です。したがって、タイムスタンプは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 

最も簡単なだけのカップルだこと。基本的には、タイムスタンプが2番目のタイムスタンプになっているので(具体的には00:00:00 Jan 1 1970 UTC秒後)、範囲別にチェックする必要があります。

+0

実際には、 '<='の代わりに '<'を使うべきだと思います。そうでなければ、arrival_dateが明日の00:00であれば、それは今日 –

関連する問題