PDA

View Full Version : DatePicker format



Trifling
20 Sep 2010, 3:01 AM
Hi, date format in DatePicker by default "month date year", e.g. "January 1 2008", how to change this format, e.g. "1 Janury 2009"

evant
20 Sep 2010, 3:05 AM
var d = new Date();
console.log(d.format('Y m d'));


All the formatting options are here: http://dev.sencha.com/deploy/touch/docs/?class=Date

Trifling
20 Sep 2010, 3:47 AM
I tried to change format in DatePicker, like in DatePicker ExtJs,e.g. "format : 'd m y'"


var datePicker =new Ext.DatePicker({
floating: false,
style:{
backgroundColor: 'red'
},
format:'d m y',
hidden: false,
frame:true,
showDoneButton: false,
name: "task_d_start",
label: "label",
useTitles: false,
height:100,
width:300,
value: {
month: 1,
day: 1,
year: 2010
},
required: true
})

but date format doesn't change in DatePicker View
It looks like
http://img814.imageshack.us/img814/1940/31961839.jpg
I need something like
http://img837.imageshack.us/img837/2134/38669446.jpg

evant
20 Sep 2010, 4:20 AM
In the next version you'll be able to use something like:



slotOrder: ['day', 'month', 'year']


I just added it.

bhupesh
19 Jan 2011, 5:39 PM
is this available yet? I tried using slotOrder in version 1.0.1a but it seem to have any effect. Or will i have to wait for sencha 2.0?

Thanks.

bhupesh
19 Jan 2011, 5:45 PM
sorry I changed it as below and seems it changed the order in picker.


datePicker = new Ext.form.DatePicker({
name : 'date',
label : 'Date',
picker : { yearFrom : 1960, slotOrder : ['day', 'month', 'year'] },
value : { year : 2030, day : 12, month : 5 }
});

But this did not change the format in actual datepicker form field.

Any suggestions?
Thanks.

sim4life
11 Feb 2011, 2:40 AM
You can write the following code snippet in


//...
onReady: function() {
//...
Ext.apply(Ext.util.Format, {
defaultDateFormat: 'd-M-Y'
});