在使用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了. 限制最小的的方法类似呐