时间弹窗获取之前自定义时间的用法Layui
<script> var timestamp3 = new Date().getTime();//当前时间的时间辍 var date = new Date(); var year = date.getFullYear(); var month = date.getMonth()+1; var day = date.getDate(); var hour = date.getHours(); var minute = date.getMinutes(); var second = date.getSeconds(); var up = second*1000 + minute*60*1000 + hour*60*60*1000 ;//当前时间之前的时间辍 var down = 86400000 - up; //当前时间之后的时间辍 layui.use('laydate', function datatime(){ var laydate = layui.laydate; var start = laydate.render({ elem: '#start_time', type: 'datetime', value: new Date(timestamp3-up), calendar: true, done: function(value, date, endDate){ end.config.min = { year: date.year, month: date.month - 1, date: date.date, hours: date.hours, minutes: date.minutes, seconds: date.seconds } } }); var end = laydate.render({ elem: '#end_time', type: 'datetime', value: new Date(timestamp3+down-1000), calendar: true, done: function(value, date, endDate){ start.config.max = { year: date.year, month: date.month - 1, date: date.date, hours: date.hours, minutes: date.minutes, seconds: date.seconds } } }); }); </script>
使用时间辍来确定时间框的自定义时间,并且时间选择框可用