layui.laydate默认当前时间时分秒,详细代码如下:
//加载日期控件信息
layui.use('laydate', function() {
var laydate = layui.laydate;
var now = new Date();
laydate.render({
elem: '#publishTime',
theme: 'molv',
type: 'datetime',
trigger: 'click',
max:4073558400000, //公元3000年1月1日
ready: function(date){
//console.log(date); //得到初始的日期时间对象:{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
this.dateTime.hours=now.getHours();
this.dateTime.minutes=now.getMinutes();
this.dateTime.seconds=now.getSeconds();
}
/*done: function(value, date, endDate){
var createTime = $("#createTime").val();
var start = new Date(createTime);
var end = new Date(value);
if(start.getTime() > end.getTime()){
$.modal.msgError("回复的发布时间不能早于被回复的发布时间!");
return;
}
}*/
});
});