Javascript 时间比较

    function datechange(obj) {

        var myDate = new Date();

        var dangqiandate = myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + myDate.getDate();

        var starttime = new Date(Date.parse(obj.replace(/-/g, "/"))).getTime();

        var endtime = new Date(Date.parse(dangqiandate.replace(/-/g, "/"))).getTime();

        if (starttime > endtime) {

            return 1;

        }

        else {

            return 2;

        }

    }

  

你可能感兴趣的:(JavaScript)