2011-02-02 3 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 일의 첫 번째 인스턴트 인 00:00:00 Feb 9 2011이며 도착 시간은 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 

. 기본적으로 타임 스탬프가 두 번째 (특히 00:00:00 Jan 1 1970 UTC부터 초)까지 내려 가기 때문에 범위별로 확인해야합니다.

+0

사실 나는'<='대신'<'를 사용해야한다고 생각합니다. 그렇지 않으면 arrival_date가 내일 00:00 일 때 오늘 일 때 여전히 사실입니다 –