0

I have used an Ext Datepicker in my panel using the following code snipped in items:

{
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
}

After selecting the date, I find that the output of the date format changes in different servers, different browsers or may be the change in the format is due to something else (which I am not sure of). The different formats I found where
Tue Nov 24 2015 00:00:00 GMT+0530 (India Standard Time) &
Mon Nov 7 00:00:00 UTC+0530 2016.

Is there a way to specify the output format of our date from the ExtJs datefield?

Freakyuser
  • 2,614
  • 15
  • 42
  • 69
  • is that related to your needs? http://stackoverflow.com/questions/8362952/javascript-date-output-formatting – bhdrk Nov 07 '14 at 08:05
  • @bhdrk I was rather expecting a direct config in ExtJs or something easier to convert my format. Is there any such thing? – Freakyuser Nov 07 '14 at 08:09

1 Answers1

1

I'm not sure about how do you get date output. but you can use Ext.Date.parse and Ext.Date.format methods for date parsing and formatting.

An example from 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
bhdrk
  • 2,991
  • 23
  • 18