短日期比较 js

function compareDate(startDate, endDate) {
                    var arr = startDate.split("-");
                    var starttime = new Date(arr[0], arr[1], arr[2]);
                    var starttimes = starttime.getTime();

                    var arrs = endDate.split("-");
                    var jstimes = new Date(arrs[0], arrs[1], arrs[2]);
                    var jstimes = jstimes.getTime();

                    if (starttimes > jstimes) {
                        return false;
                    }
                    else
                        return true;
                }
原文地址:https://www.cnblogs.com/fuge/p/3685815.html