var todate = new Ext.form.DateField({
format: 'd/m/Y',
fieldLabel: '',
id: 'txtExpireDate',
name: 'txtExpireDate',
width: 150,
allowBlank: false,
value: '',
renderTo: 'divDateExpire'
});
这段代码只显示日期。如何使用日期时间格式?
谢谢
在Ext.Form.DateField
中,当在日期选择器中选择日期时,我们不能直接显示时间。为此,我们添加侦听器:
var dtpIssueDate = new Ext.form.DateField({
listeners: {
select: function(dtpIssueDate, date) {
BindTimeWithDate(date);
}
}
});
//Bind time with date selected in the picker
function BindTimeWithDate(date) {
try {
var currentTime = new Date()
// Get a current hours and add with date.
date.setHours(currentTime.getHours());
// Get a current minutes and add with date.
date.setMinutes(currentTime.getMinutes());
dtDateTimeValue = date.format('dd/MM/yyyy HH:mm');
dtpIssueDate.SetText(dtDateTimeValue);
}
catch (e) {
alert(e.message);
}
}
extjs库中没有组件可以显示日期&这两个时间。因此,不能在其中使用日期时间格式。最接近的是这个