title: How to fix this "TypeError: Cannot find function getTime in object"?
body: <p>I'm using this function in a Google Apps Script:</p>
  
  <pre><code>function dateDiffYears() {
    var datas = [ [Date(2005, 7, 20), Date(2004, 2, 17)],
                [Date(2008, 9, 1),Date(2007, 5, 25)], 
                [Date(2010, 11, 2),Date(2010, 7, 28)], 
                [Date(2014, 0, 24),Date(2013, 1, 27)] ];
  
    for (var i= 0; i &lt; datas.length; i++){
      var d1 = datas[i][0];
      var d2 = datas[i][1];
    Logger.log("d2  = " + d2 );
    Logger.log("d2 instanceof Date = " + (d2 instanceof Date) );
    Logger.log("d1  = " + d1 );
    Logger.log("d1 instanceof Date = " + (d1 instanceof Date) );
      var t2 = d2.getTime();
      var t1 = d1.getTime();
      Logger.log("d1 = " + t1);
      Logger.log("d2 = " + t2);
      var result =  parseInt( (t2-t1)/(24*3600*1000) );
      Logger.log("diff = " + result);
         }
  }
  </code></pre>
  
  <p>As I can remember, this function worked in the past. But now, when I run it, I got this error message: <code>TypeError: Cannot find function getTime in object Sun Jan 26 2014 10:23:10 GMT-0200 (BRST). (line 22,</code> (line 22 is <code>var t2 = d2.getTime();</code>). I don't understand this error. What is wrong with the Date(yyyy, mm, dd) formate? And why the error message is talking about today date (ex:<code>Sun Jan 26 2014 10:23:10 GMT-0200 (BRST)</code>) since I'm not using <code>New Date()</code>?</p>
  
  <p><img src="https://i.stack.imgur.com/QjtSc.png" alt="enter image description here"></p>
  
  <p>How to fix it?</p>