Results 1 to 4 of 4

Thread: TimeZone ExtJs vs Java got different hours

  1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    74
    Answers
    5

    Default TimeZone ExtJs vs Java got different hours

    Hi again guys!

    I am strugling with a date problem, which is the hours getting incremented +1hour to all my date.

    So I am in GMT+1 (Lisbon, Portugal), and on server side (JAVA 8) I got this date "Sep 8, 2016 7:52:42 PM" , when my store is loaded I got this date "Thu Sep 08 2016 20:52:42 GMT+0100".

    Well, the real hour is 7:52 and not 8 (20h).

    I have another example where i pass and object in JSON and i make a

    Code:
    Ext.create('GeoC2.model.chat.Chat', Ext.decode(message));
    the moment it decodes, this happens too.

    Can Anyone have a solution to this strange behaviour?

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    Here's a thread that might help:
    https://www.sencha.com/forum/showthread.php?270836

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    74
    Answers
    5

    Default

    This doesn't help :/. I need hours minutes and seconds because this is a webChat. This solution only hide the problem cutting the hours..

    I think the problem is with Ext.decode(jsonObject) but can't understand how is this possible!!

  4. #4
    Sencha User
    Join Date
    Sep 2016
    Posts
    4

    Default

    I was dealing with this earlier today. The main problem for me was that Chrome does not parse dates by the ISO standard. You could solve this by replacing the "T" in the ISO date string to a space, but that creates an "invalid date" in IE.

    In my model, I ended up creating a convert function that creates the date object like the link above, but then I set the time using the timezone offset, like so:

    Code:
    {
         name: 'LastCommunicationTime',
         type: 'date',
         convert: function (value) {                
               var valDate = new Date(value);
               if (Ext.browser.is.Chrome) { //chrome doesn't follow ISO standards for date parsing
                     var chromeDate = new Date(valDate.getUTCFullYear(), valDate.getUTCMonth(), valDate.getUTCDate());
                      chromeDate.setTime(valDate.getTime() + valDate.getTimezoneOffset() * 60 * 1000);
                      return chromeDate;
               }
               return valDate;
          }
    },

Similar Threads

  1. Replies: 1
    Last Post: 20 Feb 2014, 11:49 AM
  2. Time field hours minutes and seconds in Extjs
    By samarth in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 23 Nov 2013, 8:17 AM
  3. Replies: 0
    Last Post: 18 Aug 2011, 1:08 AM
  4. [3.0+] Ext.ux.DateFormat / Ext.ux.TimeZone: Java-like dates and timezones
    By divestoclimb in forum Ext 3.x: User Extensions and Plugins
    Replies: 2
    Last Post: 24 May 2010, 7:31 AM
  5. My Resume -- Created in 4 hours with ExtJS
    By grutkowski in forum Community Discussion
    Replies: 10
    Last Post: 18 Nov 2007, 7:03 AM

Tags for this Thread

Posting Permissions

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