웹마스터 팁
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
날짜비교 함수
2014.12.17 23:51
function dateDiff($date1, $date2){
$_date1 = explode("-",$date1);
$_date2 = explode("-",$date2);
$tm1 = mktime(0,0,0,$_date1[1],$_date1[2],$_date1[0]);
$tm2 = mktime(0,0,0,$_date2[1],$_date2[2],$_date2[0]);
return ($tm1 - $tm2) / 86400;
}
ex)
$today = date("Y-m-d");
$day=dateDiff($result[날짜],$today);
if($day>0){ //$result[날짜]가 큰 경우
}
$_date1 = explode("-",$date1);
$_date2 = explode("-",$date2);
$tm1 = mktime(0,0,0,$_date1[1],$_date1[2],$_date1[0]);
$tm2 = mktime(0,0,0,$_date2[1],$_date2[2],$_date2[0]);
return ($tm1 - $tm2) / 86400;
}
ex)
$today = date("Y-m-d");
$day=dateDiff($result[날짜],$today);
if($day>0){ //$result[날짜]가 큰 경우
}
감사합니다~
wc3school에서는 이렇게 쓰더라고요.. ㅎ
$date1=date_create("2013-03-15");
$date2=date_create("2013-12-12");
$diff=date_diff($date1,$date2);
echo $diff->format("%R%a days");