close
要利用strtotime函數
計算日期的大小
以下為範例
$today = date('Y-m-d') ;
$thisday = '2017-04-20';
if(strtotime($today)>strtotime($thisday))
echo '今天已過20號喔!';
else
echo '還沒到20號喔!';
也可以把上面變成function喔!
以下為function
function comparison_date($finaldate){
$todate = date('Y-m-d') ;
if(strtotime($todate)>strtotime($finaldate))
$message = '今天已過'.$finaldate.'喔!';
else
$message = '還沒到'.$finaldate.'號喔!';
return $message;
}
文章標籤
全站熱搜