Results 1 to 10 of 10

Thread: Timezone different in various browsers ( Chrome / IE )

  1. #1

    Default Timezone different in various browsers ( Chrome / IE )

    Hello,
    i got a grid which shows one column including one date.
    Code:
    {                            xtype: 'gridcolumn',
                                renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
                                    if(record.data.Gesendet === true){
                                        return Ext.Date.format(value, 'd.m.Y H:i:s');
                                    } else {
                                        return ' - ';
                                    }
                                },
                                width: 120,
                                align: 'center',
                                dataIndex: 'Gesendet_am',
                                text: 'Gesendet am'
                            }
    If i am returning store without formatting. I get
    "Fri May 24 2013 12:14:14 GMT+0200 (W. Europe Daylight Time)" in Chrome
    and
    "Fri May 24 12:18:19 UTC+0200 2013" in IE.

    If i format it to "d.m.Y H:i", chrome shows me
    "24.05.2013 14:01:23" (+2 hours)
    and
    IE "24.05.213 12:01:23" (correct time).

    Why is that and how do i solve it?
    Will this "error" be in other browser like Firefox,Safari,Opera, etc, too?

  2. #2

    Default

    Maybe it is easier to understand if i just show you pictures.
    This is the JSON-Value which is sent to both browsers in column named "Gesendet am":
    "2013-05-28T12:27:08.31"


    Chrome [Timezone: "Tue May 28 2013 11:47:57 GMT+0200 (W. Europe Daylight Time)
    Time in Chrome is incorrect ( Time + 2h in Chrome ) 13:09:51 28.05.2013

    Output: Chrome_TimeZone_GMt.PNG




    Exact same JSON-Values in Internet Explorer at the same time:



    IExplorer [Timezone: "Tue May 28 12:11:11 UTC+0200 2013" ]
    Time in IE is correct 11:09:51 28.05.2013
    Output:
    IExplorer_TimeZone_GMT.PNG

    Does anyone know what Chrome has GMT+0200 (WEDT) and IE has UTC+0200?

    I didn't find solutions so far. Every single convertion effects both browsers and the difference is always 2hours.

    Any ideas?

    Thank you
    Attached Images Attached Images

  3. #3
    Sencha User
    Join Date
    Dec 2010
    Posts
    23

    Default

    Hi,

    I have seen that date error conversion in the browsers for long time even with Flash and Flex,
    the solution we found was to do not use Date, and use a string with the format we wanted to show.

    Modify the store procedure and send the date formatted as a string. This way we defined what format we want, specially we use: YYYY-MM-DD because as a string /date it will sort correctly.

    we use MS SQL, we did it: Select CONVERT(char(10), PLAY.[start_time], 111) AS FINISH_TIME ...
    there are a lot of formats (111, 109, 121...)

    Paul

  4. #4

    Default

    Hi again,
    the problem was a weird one:
    I was logged into Chrome with my Google-Account and so i logged off. Now the time is correct shown. ( Logging in again in Chrome = i still get correct time => a bug ? )
    But a new issue appeared:
    If i am opening Internet Explorer document-mode IE7 and IE8=> no date-value is shown.
    If i change it to "standards" or "quirks" time is shown but with a delay of -1 hour.
    Just document-mode IE9 shows correct time.

    What has the time to do with the document-modi?

  5. #5

    Default

    I am really sorry to post again,
    but now i am really sure that the 2hour timeshift comes from the dateformat.
    If i change the field's model-type to "date" +2 hours are added in Sencha Design View and Chrome.
    Other browsers like IE or Firefox are showing the correct time.

    Isn't this a bug and i should report this to the bug-forum?
    I am really desperate how to solve that.
    I searched a lot and i didn't find a solution for it.

    Chrome and SenchaDesign View:
    ChromeAndSenchaDesignView.PNG


    IE and FireFox:
    IEAndFirefox.PNG

    Does it have an effect which proxy i am using?
    To get those data i use a simple JSON-Store(AJAX-Proxy) filled with:

    Code:
    [    
         {
            "Date_typed" : "2013-06-05T14:35:00.0000000",
            "Date_nontyped" : "2013-06-05T14:35:00.0000000"
        }
    ]

  6. #6
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,250

    Default

    The important thing you've left out is the model. If it's like this:

    Code:
    {
        name: 'foo',
        // dateFormat: '', Date, no format!
        type: 'date'
    }
    This means that when the string comes from server -> client, it passes the string to the default browser date constructor. This means you're up to the mercy of how the browser would like to parse the value.

    It's covered pretty thoroughly in the docs:

    Serves as a default for the dateReadFormat and dateWriteFormat config options. This will be used in place of those other configurations if not specified.

    A format string for the Ext.Date.parse function, or "timestamp" if the value provided by the Reader is a UNIX timestamp, or "time" if the value provided by the Reader is a javascript millisecond timestamp. See Ext.Date.

    It is quite important to note that while this config is optional, it will default to using the base JavaScript Date object's parse function if not specified, rather than Ext.Date.parse. This can cause unexpected issues, especially when converting between timezones, or when converting dates that do not have a timezone specified. The behavior of the native Date.parse is implementation-specific, and depending on the value of the date string, it might return the UTC date or the local date. For this reason it is strongly recommended that you always specify an explicit date format when parsing dates.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  7. #7

    Default

    Hi evant,
    thank you for your response, but i still don't know what to define in dateFormat.
    Using "timestamp" i receive "Thu Jan 01 1970 01:33:33 GMT+0100 (W. Europ Standart Time")
    if i am using "U" => i get empty cells, same with any other input of formatting.

    This is the format i am receving with JSON:

    YYYY-MM-DDThh:mmsTZD = 2013-06-05T14:35:00.0000000Could you give me an explizit example how wto set my "dateFormat"?Thanks alot

  8. #8
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,250
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  9. #9

    Default

    Thank you very much it worked well,
    it should be explained better in documentary.

    Your explanation was a lot better

    Just one last question. As i wrote "timestamp" in "dateFormat" why did i get 01.01.1970 or any with any other validation i got "". Just "c" as you told me, worked fine?

    Do you have an explanation for that?

  10. #10
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,250

    Default

    Because they're not the same thing. You're sending a string back from the server, so it needs to be parsed into a date object. If you give it the wrong format, it won't parse correctly.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

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
  •