[Turn] js to determine whether today's date exceeds the specified date

method function:

function FormatDate (strTime) {
            var date = new Date(strTime);
            return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
        }

Call method:

            var today = new Date();
            var today_time =  FormatDate(today);
            if(today_time>'2018-4-25'){
                alert( 'Activity has ended' );
                 return  false ;
            }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324852645&siteId=291194637