function test(){ comptime('2010-06-08 20:01','2010-06-08 21:01'); } function comptime(beginTime,endTime){ var beginTimes=beginTime.substring(0,10).split('-'); var endTimes=endTime.substring(0,10).split('-'); beginTime=beginTimes[1]+'-'+beginTimes[2]+'-'+beginTimes[0]+' '+beginTime.substring(10,19); endTime=endTimes[1]+'-'+endTimes[2]+'-'+endTimes[0]+' '+endTime.substring(10,19); var a =(Date.parse(endTime)-Date.parse(beginTime))/3600/1000; if(a<0){ alert("小于"); return -1; }else if (a>0){ alert("大于"); return 1; }else if (a==0){ alert("等于"); return 0; } }
比较时间的大小
最新推荐文章于 2023-09-08 14:54:00 发布