在grid.panel上显示时间的数据,需要将数据时间戳转换格式,在对应的model上添加相应的代码。
{
name : 'startDate' ,
type : 'string' ,
convert:function (value) {
var startDate = Ext.Date.format(new Date (value),"Y/m/d" );
return startDate;
}
}
或者在view视图上面添加render事件
{
dataIndex: 'createTime' ,
cls: 'certbt' ,
format:'Y-m-d' ,
renderer : function (val) {
var CurrentDate="" ;
var newDate = new Date ();
newDate.setTime(val);
var newTime = newDate;
var year=newTime.getFullYear();
var month=newTime.getMonth()+1 ;
var day=newTime.getDate();
var hours=newTime.getHours();
var minutes=newTime.getMinutes();
var seconds=newTime.getSeconds();
CurrentDate += year + "/" ;
if (month >= 10 ){
CurrentDate += month + "/" ;
}else {
CurrentDate += "0" + month + "/" ;
}
if (day >= 10 ){
CurrentDate += day ;
}else {
CurrentDate += "0" + day ;
}
var Time =CurrentDate+" " +hours+":" +minutes+":" +seconds;
return '<span>' +Time+'</span>'
}
}
在controller层进行转换
getMyDate:function (str) {
var oDate = new Date (str),
oYear = oDate.getFullYear(),
oMonth = oDate.getMonth()+1 ,
oDay = oDate.getDate(),
oHour = oDate.getHours(),
oMin = oDate.getMinutes(),
oSen = oDate.getSeconds(),
oTime = oYear +'-' + this .getzf(oMonth) +'-' + this .getzf(oDay) +' ' + this .getzf(oHour) +':' + this .getzf(oMin) +':' +this .getzf(oSen);
return oTime;
},
getzf:function (num) {
if (parseInt (num) < 10 ){
num = '0' +num;
}
return num;
}
getMyDate(str);