<hr>
<div id="year_month_day"></div>
<hr>
<div id="time"></div>
<script type="text/javascript">
// 年月
var date = new Date()
var year = date.getFullYear()
var month = date.getMonth()+1
var year_month = document.getElementById("year_month")
var html = year + "年" + month + "月"
year_month.innerHTML = html
//年月日
var day = date.getDay()
var year_month_day = document.getElementById("year_month_day")
html += day + "日"
year_month_day.innerHTML = html
//实时时间
var time = document.getElementById("time")
setInterval(function () {
var date = new Date()
var year = date.getFullYear()
var month = date.getMonth()+1
var day = date.getDay()
var hours = completion(date.getHours())
var minutes = completion(date.getMinutes())
var seconds = completion(date.getSeconds())
var html = year + "年" + month + "月"
html += day + "日"
html += hours + ":" + minutes + ":" + seconds
time.innerHTML = html
},1000)
function completion(num) {
if(num<10){
return "0"+ num
}
return num
}
</script>
{xtype: "datefield",
name: "date",
fieldLabel: "日期",
editable: true,
emptyText: "--请选择--",
format: "Y-m",//这块就是年月
width: 180
}
format参数就是定义年月日的参数,按照自己的需求定义就好,你的是年月所以只需要写
format:"Y-m"就可以了