方法函數:
function FormatDate (strTime) { var date = new Date(strTime); return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate(); }
調用方法:
var today = new Date(); var today_time = FormatDate(today); if(today_time>'2018-4-25'){ alert('活動已結束'); return false; }