I am getting a date in the form of string date: '2022-07-15T09:29:24.958922Z[GMT]', When I convert it in to date then I get error invalid date. Does someone know how to solve it?
const myDate = response; // '2022-07-15T09:29:24.958922Z[GMT]'
this.transactionDate = new Date(myDate);
So the problem is [GMT] in your response string.
Either your response should be something like this
new Date("Fri Jan 20 2022 11:51:36 GMT-0500")
or you need to remove [GMT] from your existing string
var datestring ='2022-07-15T09:29:24.958922Z[GMT]';
datestring.substr(0,datestring.indexOf('['));
new Date(datestring)
var withGMT = new Date("Fri Jan 22 2022 11:51:36 GMT-0500")
console.log(withGMT);
var dateString ='2022-07-15T09:29:24.958922Z[GMT]';
var withoutGMT=dateString.substr(0,dateString.indexOf('['));
console.log(new Date(withoutGMT))