javascript 如何从 ExtJs 中的 DateField 获取日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14873419/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I get Date From DateField In ExtJs
提问by user2000423
How can I get only date like 02/8/2013 mm/dd/yyyyfrom datefield in extjs 4.0 supported on all browser.
我怎样才能从所有浏览器支持的 extjs 4.0 中的 datefield只获取像02/8/2013 mm/dd/yyyy这样的日期。
my code is as follows
我的代码如下
items: [{
xtype: 'datefield',
fieldLabel: 'Date',
format: 'm/d/Y',
altFormats: 'm/d/Y',
},
and i am getting a value from this field like this
我从这个领域得到了这样的价值
date = Ext.getCmp('configuration-section-contact-form-date-of-issue').getValue();
by using above line i get complete UTC time but I want only date like 02/8/2013.how can i get please help me. thanks..
通过使用上面的行,我得到了完整的 UTC 时间,但我只想要像 02/8/2013.how 这样的日期,请帮助我。谢谢..
回答by Vlad
回答by axel.michel
Try this:
试试这个:
Ext.getCmp('configuration-section-contact-form-date-of-issue').getValue().format('m/d/Y');
回答by sushant jain
You can use "Ext.util.Format.Date" method to format the date in desired format.
您可以使用“Ext.util.Format.Date”方法以所需格式格式化日期。
Ext.util.Format.Date(Ext.getCmp('configuration-section-contact-form-date-of-issue').getValue(),'m/d/Y')
回答by Solange
I had this problem today, I used that way and it worked:
我今天遇到了这个问题,我使用了这种方式并且它有效:
var searchText = Ext.util.Format.date(Ext.getCmp('pes1').getValue(), 'd/m/Y');