Results 1 to 5 of 5

Thread: [resolved] timefield format?

  1. #1

    Default [resolved] timefield format?

    Hello all!

    I use time and datefield of Ext and I have a little question about the timefield.

    To know what I need, lets see how I use the datefield.

    I have a date in this format : "Y-m-d" (from mysql) and my date format to display is "j/n/Y"... So when I set the value to the datefield I do this :

    HTML Code:
    myDateField.dateFormat = "Y-m-d";
    myDateField.setValue(myValue);
    And It shows my date in the format of my config object : "j/n/Y"...

    Perfect!

    But is it possible to have the same thing for timeField?

    For example, I want that the displayed time format is "H:i"... But the data I receive is "H:i: s"

    Is it possible to do something like this :
    HTML Code:
    myTimeField.timeFormat = "H:i:s";
    myTimeField.setValue(myValue);
    So the displayed hour will be "H:i"?

    I hope I'm clear enough


    Thank you!
    Last edited by Nikoms; 8 Apr 2008 at 1:21 PM. Reason: resolved

  2. #2
    Sencha User dlbjr's Avatar
    Join Date
    Oct 2007
    Location
    Cache, OK USA
    Posts
    281

    Default Hope this helps

    Code:
     
    //Use This for object
    myTimeField.timeFormat = 'H:i';
    myTimeField.setValue(myValue);
     
    //Use this when submitting form
    form.getForm().submit( {
         params: {
              mtime: Format.date(myDateField, 'H:i:s')
         },
         url : 'WhatEver',
         waitMsg : 'Saving data...'
    });
     
    
    dlbjr - David L. Bryant Jr.

    Owner of
    dlbjr Technology Consulting
    Web2 System Developer & Consultant
    Focused on C.I. - Six Sigma - Shingo - Lean Technologies
    [email protected]

    Owner of:
    Attractive Graphics - "custom screen printing"
    [email protected]

  3. #3

    Default doesn't work

    It does'nt work

    I forgot to specified that the format was in the config...

    HTML Code:
    timeField = new Ext.form.TimeField({format:"H:i",name:name,renderTo:oTable.child('td.datetime_timeField'),invalidClass:"error"});
    ....
    ....
    var myValue = "18:10:00";
    timeField.timeFormat = "H:i:s";
    timeField.setValue(myValue);
    This doesn't work and let the field empty...

  4. #4
    Sencha User dlbjr's Avatar
    Join Date
    Oct 2007
    Location
    Cache, OK USA
    Posts
    281

    Default Value must be a date object!

    Code:
    //Your code
    var myValue = "18:10:00";
    timeField.timeFormat = "H:i:s";
    timeField.setValue(myValue);
    Code:
    //Try This
    var myValue = '18:10:00';
    //Sets how the time will be viewed in the drop down.
    timeField.timeFormat = 'H:i';
    //Set the default value
    timeField.setValue(Date.parseDate(myValue, 'H:i:s'));
    dlbjr - David L. Bryant Jr.

    Owner of
    dlbjr Technology Consulting
    Web2 System Developer & Consultant
    Focused on C.I. - Six Sigma - Shingo - Lean Technologies
    [email protected]

    Owner of:
    Attractive Graphics - "custom screen printing"
    [email protected]

  5. #5

    Default I love you :)

    Thank you very much it works!
    this line isn't necessary because I already specified the format in the config object :
    Code:
    timeField.timeFormat = 'H:i';
    So this is it, ... simple
    Code:
    var myValue = '18:10:00';
    timeField.setValue(Date.parseDate(myValue, 'H:i:s'));
    Thank you again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •