我在面板中使用Ext Datepicker
使用以下代码剪切了以下代码:
{
xtype: 'datefield',
id : 'usap3',
anchor: '100%',
name: 'date',
margin: '2 0 2 20',
format: 'd/m/Y',
width: 320,
altFormats: 'd-M-y',
fieldStyle: 'text-align: center;',
height: 26, editable: false,
fieldLabel: date+'<span style="color: red"> * </span>',
labelWidth: 120
}
选择日期后,我发现日期格式的输出在不同的服务器,不同的浏览器中发生变化,或者格式的变化可能是由于其他原因(我不确定)。我找到的不同格式
Tue Nov 24 2015 00:00:00 GMT+0530 (India Standard Time)
&amp;
Mon Nov 7 00:00:00 UTC+0530 2016
。
有没有办法从ExtJs datefield
指定我们日期的输出格式?
答案 0 :(得分:1)
我不确定你如何获得日期输出。但您可以使用Ext.Date.parse和Ext.Date.format方法进行日期解析和格式化。
来自Ext.Date apidoc的示例:
// Sample date:
// 'Wed Jan 10 2007 15:05:01 GMT-0600 (Central Standard Time)'
var dt = new Date('1/10/2007 03:05:01 PM GMT-0600');
console.log(Ext.Date.format(dt, 'Y-m-d')); // 2007-01-10
console.log(Ext.Date.format(dt, 'F j, Y, g:i a')); // January 10, 2007, 3:05 pm
console.log(Ext.Date.format(dt, 'l, \\t\\he jS \\of F Y h:i:s A')); // Wednesday, the 10th of January 2007 03:05:01 PM