2

I am trying to debug a really strange string length problem in Internet Explorer 11.

I cannot work out why it is telling me that the string "01/03/2017" has a length of 15?

Can anyone tell me what I am doing wrong please?

enter image description here

Here is the function

function stringToUKDate(strDate) {
debugger;
newDate = strDate.trim().substr(0, 10);
var dateSplit = newDate.split("/");
var newDate = new Date(dateSplit[2], dateSplit[1] - 1, dateSplit[0], 0, 0, 0);
// return the new date
return newDate;
}

encodeURIComponent(strDate) gives me %E2%80%8E01%E2%80%8E%2F%E2%80%8E02%E2%80%8E%2F%E2%80%8E2017

Ameya Deshpande
  • 3,580
  • 4
  • 30
  • 46
Trevor Daniel
  • 3,785
  • 12
  • 53
  • 89

1 Answers1

0

I think that issue come from your type, maybe the conversion adds some chars (maybe non-breaking spaces or just not display chars but are counted...) try the date format or a tostring