代码:
复制代码 代码示例:
//var Stime = $( '#tb_starttime' ).val();
//var Etime = $( '#tb_endtime' ).val();
var Stime = "11/20/2013 16:26";
var Etime = "11/20/2013 16:26";
var beginTimes = Stime.val().substring(0, 10).split('-');
var endTimes = Etime.val().substring(0, 10).split('-');
beginTime = beginTimes[1] + '-' + beginTimes[2] + '-' + beginTimes[0] + ' ' + Stime.substring(10, 16);
endTime = endTimes[1] + '-' + endTimes[2] + '-' + endTimes[0] + ' ' + Etime.substring(10, 16);
beginTime = beginTime.replace( /-/ig , '/' );
endTime = endTime.replace( /-/ig , '/' );
var compTime = ( Date.parse(endTime) - Date.parse(beginTime)) / 3600 / 1000;
if (compTime < 0) {
alert("endTime小!");
} else if (compTime > 0) {
alert("endTime大!");
} else if (compTime == 0) {
alert("时间相等!");
} else {
return 'exception'
}