<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
<link th:href="@{/css/jquery.datetimepicker.css}" rel="stylesheet"/>
<link th:href="@{/css/bootstrap-datetimepicker.css}" rel="stylesheet">
<script th:src="@{/js/jquery.datetimepicker.full.js}"></script>
<html>
<body>
<input style="width: 120px;" class="time" id="stime" type="text">
</body>
</html>
<script type="text/javascript">
$(function(){
var timestamp = getNowFormatDate();
$.datetimepicker.setLocale('ch');
timeLogic();
$("#stime").val(timestamp+" 00:00");
})
//获取时间
//var st = $("#stime").val();
//var reg = new RegExp("/","g");
//st = st.replace(reg,'-');
function timeLogic(){
var logic = function(currentDateTime){
if (currentDateTime&¤tDateTime.getDay()==6){
this.setOptions({
minTime:'11:00'
});
}else
this.setOptions({
minTime:'8:00'
});
};
$('.time').datetimepicker({
onChangeDateTime:logic,
onShow:logic
});
}
function getNowFormatDate() {
var date = new Date();
var month = date.getMonth() + 1;
var strDate = date.getDate();
var hour = date.getHours();
var minutes = date.getMinutes();
var second = date.getSeconds();
if(month >= 1 && month <= 9){
month = "0" + month;
}
if(strDate >= 0 && strDate <= 9){
strDate = "0" + strDate;
}
//var currentdate = date.getFullYear()+month+strDate+" "+hour+minutes+second;
var currentdate = date.getFullYear()+"/"+month+"/"+strDate;
return currentdate;
}
</script>
以上css和js可以在我上传的springboot资源中找到