1.显示年月日
<input type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss')">
2.限制今天以后的日期不能选择
<input type="text" onClick="WdatePicker({maxDate:'%y-%M-%d')">
3.选择时间段
<input type="text" onClick="WdatePicker({dateFmt:'HH:mm:ss')">
4.开始时间不能大于结束时间
<input id="startTime" value="" type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'#F{$dp.$D(\'endTime\')}'})" name="startTime" class="Wdate"/>-
<input id="endTime" value="" type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'startTime\')}'})" name="endTime" class="Wdate"/>
5.开始时间不大于结束时间,且结束时间不小于开始时间
<input type="text" class="abnormalHight timeBtn " value="" id="starTime" name="beginDate" onclick="WdatePicker({minDate:'',maxDate:'#F{$dp.$D(\'endTime\')}'});" placeholder="选择时间" autocomplete='off'/>
<input type="text" value="" class="abnormalHight timeBtn " id="endTime" name="endDate" onclick="WdatePicker({minDate:'#F{$dp.$D(\'starTime\')}', maxDate:'%y-%M-%d'});" autocomplete='off' />
<script><
function timestampToTime(timestamp) {
var date = new Date(timestamp * 1000); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
var Y = date.getFullYear() + '-';
var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
var D = date.getDate() + ' ';
var h = date.getHours() + ':';
var m = date.getMinutes() + ':';
var s = date.getSeconds();
return Y + M + D;
};
var nowDate = new Date();
var year = nowDate.getFullYear();
var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) : nowDate.getMonth() + 1;
var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
var datetime = year + "-" + month + "-" + day; // "2018-03-26";
$("#endTime").val(datetime);
$("#starTime").val(datetime);
var numberdate = new Date(datetime).getTime() / 1000;
var startValue =timestampToTime(numberdate - 7948800) ;
/script>
后续有使用持续更新