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

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

谢谢

+0

您在谈论哪种日期时间格式?你必须让你的问题更清楚。 – Chau

回答

0

存在这样既可以显示日期时间& ExtJS的库中没有的组成部分。因此,你不能在一个日期时间格式。最近的可以得到的是with this.

希望这会有所帮助。

+2

我有这个问题的解决方案。按设定格式:'d/m/Y H:i:s' – KCuncle

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); 
    } 
}