getTime() is not a function : if you are using the function getTime() and you have the error getTime() is not a function (in javascript / Typescript ) that mean you are using the date as a String , so as a solution you must parse the Date. for that you can use this function :
Solution :

  // parse a date in yyyy-mm-dd format
 parseDate(input) {
  var parts = input.match(/(\d+)/g);
  // new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])
  return new Date(parts[0], parts[1]-1, parts[2]); // months are 0-based
}

Commentaires

  1. Pingback: Solution for : TypeScript - Get difference between two dates in days

Laisser un commentaire