1. 程式人生 > >easyui datebox 時間控制元件預設顯示當前日期

easyui datebox 時間控制元件預設顯示當前日期

 <script>
//得到當前日期
formatterDate = 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;
};

window.onload = function () { 
$('#startTime').datebox('setValue', formatterDate(new Date()));
}
    </script>