Why is the date value in the string changed to the Invalid date value in iOS?

I enter the source code I created by floating the html file in chrome. It works very well.



But when you run this on the actual iPhone WKwebview, the value is recognized as invalid. I have to compare the dates. How can we solve this problem?



js code

  var today = new Date();
  var s_date_str =
    $("#startDate").val() + " " + $("#startTime").val() + ":11";
  var e_date_str =
    $("#endDate").val() + " " + $("#endTime").val() + ":11";


  var s_date = new Date(s_date_str);
  var e_date = new Date(e_date_str);
  console.log(s_date_str);
  console.log(e_date_str);
  console.log(today);
  console.log(s_date);
  console.log(e_date);
if (to_date >= s_date) {
    alert(today is fast than startDate)
    return;
  } else if (s_date >= e_date) {
    alert(startDate is fast than endDate)
    return;
  }




console.log data

2019-11-22 10:27:11 //s_date_str

2019-11-23 10:27:11 //e_date_str

Fri Nov 22 2019 10:22:11 GMT+0900 //today

Fri Nov 22 2019 10:27:11 GMT+0900 //s_date

Sat Nov 23 2019 10:27:11 GMT+0900 //e_date



Data found on the iPhone by changing consol.log to alert

2019-11-22 10:27:11 //s_date_str

2019-11-23 10:27:11 //e_date_str

Fri Nov 22 2019 10:22:11 GMT+0900 //today

Invalid Date //s_date

Invalid Date //e_date



I'm using swift5


I tried many things. But it doesn't work.


first tried // Not working in chrome.

function parseDate(input) {
  var parts = input.split("-");
  return new Date(parts[0], parts[1] - 1, parts[2]); // Note: months are 0-based
}
var s_date = new Date(parseDate(s_date_str));




second tried // working in chrome.

var s_date = new Date(Date.parse(s_date_str));


Date.parse will operate normally when the html file is run on chrome but will not work on WKWebView.

  console.log(Date.parse(s_date_str)); 
 alert(Date.parse(s_date_str));

log and alert data


1574388551000 // chrome

NaN // ios WKwebVIew