【发布时间】:2016-04-03 21:49:16
【问题描述】:
我使用 extjs timefield 创建了一个简单的应用程序。这是代码&fiddle:
Ext.create('Ext.form.Panel', {
title: 'Time Card',
width: 300,
bodyPadding: 10,
renderTo: Ext.getBody(),
items: [{
xtype: 'timefield',
id: 'in',
fieldLabel: 'Time In',
//minValue: '6:00 AM',
//maxValue: '8:00 PM',
format: 'H:i',
increment: 30,
anchor: '100%'
}, {
xtype: 'button',
text: 'click',
handler: function(){
alert(Ext.getCmp('in').getValue());
console.log(Ext.getCmp('in').getValue());
}
}]
});
问题/问题:
- 当我使用 getValue() 时,它返回
Tue Jan 01 2008 01:00:00 GMT-0500 (Eastern Standard Time)。 我不知道为什么它会返回 2008 年? - 有没有办法捕获时区信息?
【问题讨论】:
-
看起来有问题。您应该自己设置日期部分。
-
Timefield 以及 datefield 实际值是日期对象,正如 Alexandex 在他的回答中提到的,它的初始日期设置为 2008 年 1 月 1 日。如果您想获得时间,可以使用
Ext.Date.format(Ext.getCmp('in').getValue(), 'H:i')或设置submitFormat: 'H:i'并使用Ext.getCmp('in').getSubmitValue()或仅使用Ext.getCmp('in').getRawValue()。
标签: extjs extjs4 extjs4.1 extjs5 timefield