//比較時(shí)間大小
//Date.parse()方法可以把時(shí)間轉(zhuǎn)換成毫秒
var salesdate = Date.parse($("#info_salesdate").val());
var canceldate = Date.parse($("#info_canceldate").val());
var date = new Date();
var now = Date.parse(date);
if(now < salesdate){ alert("上架時(shí)間不能大于當(dāng)前時(shí)間觉增!"); _errortime = _errortime+1;}
if(now > canceldate){ alert("下架時(shí)間不能小于當(dāng)前時(shí)間!"); _errortime = _errortime+1;}
時(shí)間格式轉(zhuǎn)換狂塘,轉(zhuǎn)換成yyyy-mm-dd hh24-mi-ss的形式
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;//拿到月份,但是取到的是上個(gè)月的月份,要+1
var strDate = date.getDate();//拿到日期
if (month >= 1 && month <= 9) {//月份處理
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {//日期處理
strDate = "0" + strDate;
}
//時(shí)間拼接
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
+ " " + date.getHours() + seperator2 + date.getMinutes()+":00";
return currentdate;