(SOLVED) getTime() is not a function ?

getTime() is not a function : if you are using the function getTime() and you have this error (in javascript / Typescript ) that mean you are using the date as a String , so as a solution you must parse the Date. See the next example to understand how solve this !
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
Marwen Mselmi
Author: Marwen Mselmi

Founder of Javatuto.com, love Java and open source stuff. Follow me on Linkedin.

Leave a comment