easyui datetimebox初始化賦值
阿新 • • 發佈:2019-01-28
預設顯示今天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;
};