在使用laydate時間插件中,避免不了要對時間的大小區域進行限制,難受的是,找了又找也沒找到關於這方面的文檔…(好像之前的版本有?)網上找到的還報錯…
所以貼代碼把
laydate.render({
elem: '#receive_time_date'
, done: function (value, date) {
var scope = $('#myModule').scope();
scope.receive_time_date = value;
scope.$apply();
},
max: getNowFormatDate()
});
function getNowFormatDate() {
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
+ " " + date.getHours() + seperator2 + date.getMinutes()
+ seperator2 + date.getSeconds();
return currentdate;
}
注意上面的 max: getNowFormatDate(),自己寫一個方法限制就ok了. 限制最小的的方法類似吶