Ok I have a very strange issue. In Netsuite (serve...
# suitescript
f
Ok I have a very strange issue. In Netsuite (server side) I am doing the following to convert a non standardized timestamp string provided by netsuite to a JS Date object:
Copy code
function nsStringToDate(str) {
    var regex = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/;
    var match = regex.exec(str);
    var date = new Date();
    date.setFullYear(parseInt(match[1]), parseInt(match[2]) - 1, parseInt(match[3]));
    date.setHours(parseInt(match[4]), parseInt(match[5]), parseInt(match[6]), 0);
    return date.toISOString();
  }
For some reason I seem to get a
Date is invalid
error on the
return date.toISOString()
. Even though the inputs are ether
2020-05-10T05:13:01
or
2020-07-09T05:13:01
any idea why this could be?