1. #1
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    376
    Vote Rating
    20
    ttbgwt will become famous soon enough

      0  

    Default Unanswered: Ext.util.Format.date question

    Why does this:
    Code:
    Ext.util.Format.date('2012-09-14', 'Y/m/d');
    return this? 2012/09/13 and not 2012/09/14

  2. #2
    Sencha User mberrie's Avatar
    Join Date
    Feb 2011
    Location
    Bangkok, Thailand
    Posts
    506
    Vote Rating
    17
    Answers
    26
    mberrie has a spectacular aura about mberrie has a spectacular aura about

      0  

    Default

    Not for me, on 4.1.1 - check out this jsFiddle: http://jsfiddle.net/bJ2qs/

  3. #3
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    376
    Vote Rating
    20
    ttbgwt will become famous soon enough

      0  

    Default

    hmm... I just ran your fiddle and I still get same results

    ext-ss.png

  4. #4
    Touch Premium Member suzuki1100nz's Avatar
    Join Date
    Apr 2011
    Location
    New Zealand
    Posts
    697
    Vote Rating
    226
    Answers
    45
    suzuki1100nz is a splendid one to behold suzuki1100nz is a splendid one to behold suzuki1100nz is a splendid one to behold suzuki1100nz is a splendid one to behold suzuki1100nz is a splendid one to behold suzuki1100nz is a splendid one to behold suzuki1100nz is a splendid one to behold suzuki1100nz is a splendid one to behold

      0  

    Default

    Hi what browser and what ExtJS version - I tested it in Chrome, IE9, Firefox with ExtJS 4.1.1 and it worked fine

  5. #5
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,344
    Vote Rating
    490
    Answers
    712
    scottmartin has a spectacular aura about scottmartin has a spectacular aura about scottmartin has a spectacular aura about

      0  

    Default

    What I use is:

    For format.date, use:
    Ext.util.Format.date('2012/09/14', 'Y/m/d');
    For the field define for date field use:
    { name : 'date_field', type : 'date', dateFormat : 'Y-m-d' },
    Scott.

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,821
    Vote Rating
    781
    Answers
    550
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default

    Note:

    The value to format. If a string is passed, it is converted to a Date by the Javascript's built-in Date.parse method.
    What does Date.parse return on that string?
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  7. #7
    Ext JS Premium Member
    Join Date
    May 2008
    Posts
    376
    Vote Rating
    20
    ttbgwt will become famous soon enough

      0  

    Default

    Code:
    Ext.getBody().update(Date.parse('2012-09-14'));
    


    returns this: 1347580800000

  8. #8
    Sencha User
    Join Date
    Mar 2015
    Posts
    2
    Vote Rating
    0
    eamorese is on a distinguished road

      0  

    Default

    This one is old but I just stumbbled in the same problem.

    In my case, I realized that the problem is not the renderer, I don't know if yours really was.
    My JSON comes with the correct date, but the grid shows 1 day before.
    Finally, I verified that it only happens on CHROME. Using FIREFOX, the correct date is displayed.

    I still don't know why Chrome does that or what the problem is.

  9. #9
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,786
    Vote Rating
    378
    Answers
    581
    skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute skirtle has a reputation beyond repute

      0  

    Default

    Most likely it's a problem with the timezone or DST. It needs someone who can reproduce the problem (I can't) to step through in the debugger to figure out where things go awry.

    It is also possible that the problem will only happen at certain times of day as modifying a Date object can pick up parts of the current date/time. I recall a similar problem where the date formatters didn't function correctly on the 31st day of the month.