JS 比较两个时间的大小

//获取当前时间
var currentTime = new Date();

//自定义指定时间,需要标准格式的时间
var customTime="2019-03-01 00:00:00";  
customTime= customTime.replace("-","/");//替换字符,变成标准格式  
customTime= new Date(Date.parse(customTime));
var time1 = new Date('2021-03-01');
var time2 = new Date('2021-09-01');

var msg=time1>time2?"time1大":"time2大";
Console.log(msg);
原文地址:https://www.cnblogs.com/qingheshiguang/p/15556873.html