From the back-end, I am retrieving this string as a date: "2017-08-16T18:35:41.611Z2017-08-16T13:35:41.611"
How can I extract the total number of minutes from this string? I tried the following:
let date = new Date("2017-08-16T18:35:41.611Z2017-08-16T13:35:41.611");
let minutes = date.getMinutes();
console.log(minutes);
But date
logs as Invalid Date
and minutes
logs as NaN
. Any ideas?
Your backend is sending you twice the date 2017-08-16T18:35:41.611Z2017-08-16T13:35:41.611
If you can't modify the backend service, you could split them by the Z and then do the function you said:
let date = new Date("2017-08-16T18:35:41.611Z2017-08-16T13:35:41.611".split("Z")[0]);
let minutes = date.getMinutes();
console.log(minutes);