1. #1
    Sencha User crocop21's Avatar
    Join Date
    May 2012
    Posts
    65
    Vote Rating
    0
    crocop21 is an unknown quantity at this point

      0  

    Default Unanswered: how to pass a date format to a Label in form panel

    Unanswered: how to pass a date format to a Label in form panel


    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

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

  2. #2
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    Answers
    124
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    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:

    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'));
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha User crocop21's Avatar
    Join Date
    May 2012
    Posts
    65
    Vote Rating
    0
    crocop21 is an unknown quantity at this point

      0  

    Default


    Quote Originally Posted by sword-it View Post
    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:

    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"

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,197
    Vote Rating
    482
    Answers
    689
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    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.

Thread Participants: 2

Tags for this Thread