2014年10月1日 星期三

判斷是否在時間區間內

判斷現在時間是否在設定的時間區間內

$test1 = '2014-10-01 00:00:00';
$test2 = '2014-10-03 00:00:00';
$now_time =  strtotime(date("Y-m-d H:i:s"));
$start = strtotime($test1);
$end =  strtotime($test2);

if($now_time >= $start && $now_time <= $end ){
 echo "在區間內";
} else {
 echo "沒有在區間內";
}

沒有留言:

張貼留言