默认显示今天0点到当前时间点
jsp
<div id="tb" style="padding-left: 10px">
开始时间:
<input name="startTime" id="startTime" class="easyui-datetimebox" style="width:160px;height:30px"/>
结束时间:
<input name="endTime" id="endTime" class="easyui-datetimebox" style="width:160px;height:30px"/>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch()" >查询</a>
</div>
js
$(function () {
var etime = new Date();
$('#startTime').datetimebox('setValue', formatterSDate(etime));
$('#endTime').datetimebox('setValue', formatterEDate(etime));
})
formatterSDate = function (date) {
var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0"+ (date.getMonth() + 1);
return date.getFullYear() + '-' + month + '-' + day+" "+00+":"+00+":"+00;
};
formatterEDate = function (date) {
var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0"+ (date.getMonth() + 1);
var hor = date.getHours();
var min = date.getMinutes();
var sec = date.getSeconds();
return date.getFullYear() + '-' + month + '-' + day+" "+hor+":"+min+":"+sec;
};