1.首先导入主要js:
效果如下图:
[img]http://dl2.iteye.com/upload/attachment/0098/2952/85d294bd-0508-36ca-a4a5-40cf4391946c.jpg[/img]
[img]http://dl2.iteye.com/upload/attachment/0098/2956/f3e46308-d4a8-382d-808e-50bfff1f2918.jpg[/img]
如果需要在开始的时候指定时间则:
2.日期选择没有到时分秒的方式。
效果如下图:
[img]http://dl2.iteye.com/upload/attachment/0098/2959/b9fb582a-6584-3e94-93ad-518ebc578cf9.jpg[/img]
[img]http://dl2.iteye.com/upload/attachment/0098/2961/98c81679-7474-32ab-82b7-b2c6ee6d6ac1.jpg[/img]
<script type="text/javascript" src="date/My97DatePicker/WdatePicker.js"/>
<label style="padding: 3px"><span>开始时间:</span>
<input type="text" id="dd" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'sdd\',{M:-4});}',maxDate:'#F{$dp.$D(\'sdd\',{d:0});}'})" class="Wdate" />
</label>
<label style="padding: 3px">
<span>结束时间:</span>
<input type="text" id="sdd" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'dd\');}',maxDate:'#F{$dp.$D(\'dd\',{M:+4});}'})"
class="Wdate" />
</label>
效果如下图:
[img]http://dl2.iteye.com/upload/attachment/0098/2952/85d294bd-0508-36ca-a4a5-40cf4391946c.jpg[/img]
[img]http://dl2.iteye.com/upload/attachment/0098/2956/f3e46308-d4a8-382d-808e-50bfff1f2918.jpg[/img]
如果需要在开始的时候指定时间则:
$(function() {
//设置历史时间
var date = new Date();
month = (date.getMonth()+1)<10?'0'+(date.getMonth()+1):date.getDate() ;
day = date.getDate()<10?'0'+(date.getDate()):date.getDate() ;
hours = date.getHours()<10?'0'+(date.getHours()):date.getHours() ;
minutes = date.getMinutes()<10?'0'+(date.getMinutes()):date.getMinutes();
seconds = date.getSeconds()<10?'0'+(date.getSeconds()):date.getSeconds();
$("#开始时间id").val(date.getFullYear()+'-'+month+'-'+day+' 00:00:00');
$("#结束时间id").val(date.getFullYear()+'-'+month+'-'+day+' '+hours+':'+minutes+':'+seconds);
});
2.日期选择没有到时分秒的方式。
<input id="开始时间" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" class="Wdate"/>
<input id="结束时间" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'exestate\')}',dateFmt:'yyyy-MM-dd'})" class="Wdate"/>
效果如下图:
[img]http://dl2.iteye.com/upload/attachment/0098/2959/b9fb582a-6584-3e94-93ad-518ebc578cf9.jpg[/img]
[img]http://dl2.iteye.com/upload/attachment/0098/2961/98c81679-7474-32ab-82b7-b2c6ee6d6ac1.jpg[/img]