Reputation: 21
var todate = new Ext.form.DateField({
format: 'd/m/Y',
fieldLabel: '',
id: 'txtExpireDate',
name: 'txtExpireDate',
width: 150,
allowBlank: false,
value: '',
renderTo: 'divDateExpire'
});
This code to display only date. How to use datetime format?
Thank you
Upvotes: 1
Views: 17492
Reputation: 11
In Ext.Form.DateField
we're not able to show time directly when selecting a date in date picker. For that we add listeners:
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);
}
}
Upvotes: 1
Reputation: 4185
There is no component in extjs library which can display date & time both. And thus, you cannot use date time format in one. The closest one can get to is with this.
Hope this helps.
Upvotes: 0