引入相应css和js文件
<link rel="stylesheet" href="/static/build/layui.css" media="all">
<script type="text/javascript" src="/home/js/datetimepicker/laydate.js"></script>
<script src="https://cdn.bootcss.com/moment.js/2.20.1/moment.js"></script>
html代码:
<input type="text" id='add_date'>
js代码:
laydate.render({
elem: '#add_date',
type: 'date',
format:'yyyy/MM/dd',
min:minDate(),
change:function(value,date){
console.log(value)
console.log(date)
},
btns:['clear','confirm']
});
//设置只能选择未来时间
function minDate(){
var now = new Date();
return now.getFullYear()+"-" + (now.getMonth()+1) + "-" + now.getDate();
}
ps:如果只想要小时和分钟不要秒
*显示的插件上只能选择小时和分钟后,看下面的样式;然后代码上初始化设置*
.layui-laydate-content>.layui-laydate-list {
padding-bottom: 0px;
overflow: hidden;
}
.layui-laydate-content>.layui-laydate-list>li{
width:50%
}
.merge-box .scrollbox .merge-list {
padding-bottom: 5px;
}
想要修改其他的功能和某些东西的链接
https://www.layui.com/doc/modules/laydate.html