Incorrect date value displayed in IE11; Works fine in Chrome and Firefox

I have been dealing with this problem for past two days and not able to figure out what’s wrong.

Please consider my JSFiddle here

I used moment.js over there and for some unknown reason, in IE 11, it keeps on showing today’s date. However, everything is fine in Firefox and Chrome. Please let me know how can I fix this?

The following is the part of code where I am doing this testing :

var iconrenderer = function (row, columnfield, value, defaulthtml, columnproperties) {

                console.log("Test for Date Values using moment.js");
                //console.log(value.toString());
                console.log(moment(value).format('MM/DD/YY'));


                return '<span style="position: relative; width: 100%; margin: 4px; float: ' + columnproperties.cellsalign + ';">' + moment(value).format('MM/DD/YY') + '<img src="https://www.jqwidgets.com/public/jqwidgets/styles/images/icon-down.png" style="position: absolute; right: 5px;" /></span>';
                
                
            }

What’s with the "dot zeroes"after the hour:minutes:seconds?

That’s how I am getting from the server. I believe that’s for timezone. Something like this : MM/dd/yyyy hh:mm:ss.z

If you’re getting “dot z” from the server you’re not getting “dot zero”.
Try not changing that.

Here is one of the response from the server 2018-03-22 16:20:00.0.

Just like MM stands for Month, z stands for timezone. So, I won’t be getting z but some number.

I have also tried not changing it. It will show today’s date with time zone on IE 11. It won’t show today’s date on Firefox and Chrome but the dates mentioned in the Javascript code.

Offhand I can’t think of an ISO with that format. What is outputting the date in that format?

It’s like this (mentioned in the JSFiddle)

I’m more interested in where the dates for this come from. They are what’s causing the problem.

var data = [
    { name: 'A', date: '07/15/2014 05:00:00.0',des:'This is for A' },
    { name: 'A', date: '08/16/2016 06:00:00.0',des:'This is for 2A' },
    { name: 'A', date: '07/15/2015 07:00:00.0',des:'This is for 3A' },
    { name: 'B', date: '07/15/2016 07:00:00.0',des:'This is for B' },
    { name: 'B', date: '08/16/2016 07:00:00.0',des:'This is for 2B' },
    { name: 'B', date: '09/15/2016 07:00:00.0',des:'This is for 3B' },
    { name: 'C', date: '08/15/2015 07:00:00.0',des:'This is for C' },
    { name: 'D', date: '12/15/2015 07:00:00.0',des:'This is for D' },
    { name: 'E', date: '11/15/2015 07:00:00.0' ,des:'This is for E'}
];

It turned out to be the date issue. The Java webservice was pulling date as string in the resultset of JDBC connection and hence the dates were messing up. I fixed the bug in the Java webservice and it started working fine now. The final date format I am receiving now is just 07/15/2014.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.