1
var todate = new Ext.form.DateField({
        format: 'd/m/Y', 
        fieldLabel: '',
        id: 'txtExpireDate',
        name: 'txtExpireDate',
        width: 150,
        allowBlank: false,
        value: '',
        renderTo: 'divDateExpire'
    });

此代码仅显示日期。如何使用日期时间格式?

谢谢

4

2 回答 2

1

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);
  }
}
于 2012-07-12T12:33:14.540 回答
0

extjs 库中没有可以同时显示日期和时间的组件。因此,您不能同时使用日期时间格式。最接近的就是这个。

希望这可以帮助。

于 2011-12-02T09:29:04.023 回答