PDA

View Full Version : how to pass a date format to a Label in form panel



crocop21
25 Jul 2012, 6:25 AM
Hi all, i am trying to pass from my records from my grid to a form with label but i have the problem passing the column type date to a label

Is showing me like this: Mon Oct 22 00:00:00 UTC+0200 2012

When i need something like this : 10/22/2012


Ext.getCmp('lb_mydate').setText(rec.getAt(rowIndex).data.mydate.);

Thanks

sword-it
25 Jul 2012, 6:37 AM
If you want to print your date as some format, then you need to format that date before setting that date in label. Review the following code:




// as you said that your date is coming like 'Mon Oct 22 00:00:00 UTC+0200 2012'
// then you need to do like new Date('Mon Oct 22 00:00:00 UTC+0200 2012').format('m/d/Y')
// id gives as - "10/22/2012"
Ext.getCmp('lb_mydate').setText(new Date(rec.getAt(rowIndex).data.mydate).format('m/d/Y'));

crocop21
25 Jul 2012, 6:46 AM
If you want to print your date as some format, then you need to format that date before setting that date in label. Review the following code:




// as you said that your date is coming like 'Mon Oct 22 00:00:00 UTC+0200 2012'
// then you need to do like new Date('Mon Oct 22 00:00:00 UTC+0200 2012').format('m/d/Y')
// id gives as - "10/22/2012"
Ext.getCmp('lb_mydate').setText(new Date(rec.getAt(rowIndex).data.mydate).format('m/d/Y'));


mmm y tried how u said and all my form is showing the labels without records.. only is showing "My Label"

scottmartin
25 Jul 2012, 7:45 AM
From the console:

> today = new Date()
?Wed Jul 25 2012 10:44:34 GMT-0500 (CDT)
> newdate = Ext.util.Format.date(today, 'm/d/Y');
?"07/25/2012"

Scott.