1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    61
    Vote Rating
    2
    cahello is on a distinguished road

      0  

    Default Answered: How to extract only the date from the Datefield object

    Answered: How to extract only the date from the Datefield object


    Hi,

    I have an xtype datefield and timefield. On clicking a button, I am retrieving the values. The values, however, give information which I do not need. How can I convert these objects to string and manipulate accordingly?
    For eg: the timefield returns some date, time and some text like (eastern standard time). I only want the time in hours and min and attach extra details myself.

    Thanks

  2. Try this:
    Code:
    Ext.Date.format(timefield.getValue(), 'H:i:s');

  3. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      1  

    Default


    Try this:
    Code:
    Ext.Date.format(timefield.getValue(), 'H:i:s');

  4. #3
    Sencha User
    Join Date
    Jul 2012
    Location
    USA
    Posts
    29
    Answers
    2
    Vote Rating
    0
    jenis35@yahoo.co.in is on a distinguished road

      0  

    Default


    If you are using any server side code then you can convert your date like the one I have done it. You can specify the required format you want. Let me know if any doubt.
    Java code :
    Code:
    SimpleDateFormat extJSDateFormat, requiredFormat = null;
            Date date = null;
            try {
                extJSDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
                System.out.println("Old date:" + oldDate);
                // String oldDate = "2011-03-10T11:54:30.207Z";
                date = extJSDateFormat.parse(oldDate.substring(0, 19));
                requiredFormat = new SimpleDateFormat("MM/dd/yyyy");
                System.out.println("OldDate:" + oldDate);
                System.out.println("NewDate:" + requiredFormat.format(date));
            } catch (Exception e) {
                e.printStackTrace();
            }
    Thanks.
    J.M.

  5. #4
    Sencha User
    Join Date
    May 2012
    Posts
    61
    Vote Rating
    2
    cahello is on a distinguished road

      1  

    Default


    Thanks both of you. I tried this as suggested and it worked!

    Code:
    Ext.Date.format(timefield.getValue(), 'H:i:s');