0

I'm working with jQuery datepicker and in Internet Explorer 11 the same date (2017/Aug/12) appears twice and the following (13) doesn't exist. Checking the console I found the following difference between IE11 and Chrome.

Chrome

var a = new Date(2017,07,13)

Returns Sun Aug 13 2017 01:00:00 GMT-0300 (CLST)

IE11

var a = new Date(2017,07,13)

Returns = Sat Aug 12 2017 23:00:00 GMT-0400 (CLST)

So in IE11 I can't ask for 2017, Aug, 13.

This is because in that day my country change the timezone, but just it's wrong in IE11.

Some idea how fix that?

Edit -
I found the root of the issue, in some place we hace the next line:

day.setHours(0, 0, 0, 0);

and that broke the Date Object and change the 13 of August to 12, I dont know why yet.

Jordan
  • 45
  • 5
  • Specify `12` for the hour, if you're only interested in the date. But `` makes date pickers obsolete ;) – Niet the Dark Absol Nov 16 '16 at 17:35
  • 3
    @NiettheDarkAbsol The lack of support from browsers does not.... – epascarello Nov 16 '16 at 17:35
  • @epascarello ... [Granted](http://caniuse.com/#feat=input-datetime). I naively assumed that if Edge had it, other browsers did too. Come on Firefox... – Niet the Dark Absol Nov 16 '16 at 17:36
  • Sadly support lacks http://caniuse.com/#feat=input-datetime – epascarello Nov 16 '16 at 17:37
  • I'm guessing that if you did `a.getUTCDate()` on both you'd get the same value... – Heretic Monkey Nov 16 '16 at 17:48
  • Finally I use this for that case: day.setHours(day.getHours() + 2); so i get the date Sat Aug 12 2017 23:00:00 GMT-0400 (CLST) and I add 2 hours. Now this is working, but I dont know if exist a better solution, because this will be a fix to rewritte every year :( – Jordan Nov 16 '16 at 17:56
  • Try supplying zeros for the missing Date constructor parameters. – Jared Smith Nov 16 '16 at 17:58
  • I found the root of the issue, in some place we hace the next line: day.setHours(0, 0, 0, 0); and that broke the Date Object and change the 13 of August to 12, I dont know why yet. – Jordan Nov 16 '16 at 19:31
  • 1
    @Jordan If you provide a working code snippet so that the problem was easily reproduced, it would be easier to help. – Mic Nov 16 '16 at 19:46
  • @Mic I have this line var momentDate = moment(model.get("value"), model.get("dateFormat").toUpperCase()); model.get("value") returns "13/08/2017" but If I ask for the final value of momentDate is Sat Aug 12 2017 At 23:00 – Jordan Nov 17 '16 at 13:48

0 Answers0