Google Apps Script Returning Wrong Month (subtracting 1)
google-apps-script
Solution
No, you are not doing anything wrong. `Date.getMonth()` is 0-based , rather than 1-based. In other words, it returns values in the range 0 to 11 instead of 1 to 12.
Problem
With this simple script in GAS: ``` function testingStuff(){ var date = new Date(); var yr = date.getYear(); var dt = date.getDate(); var mt = date.getMonth(); Logger.log("year: " +yr); Logger.log("date: " +dt); Logger.log("month: " +mt); } ``` I get this as my response: ``` year: 2013 date: 28 month: 2 ``` Today is March 28th 2013. I have no clue what could be causing this error. Does anybody else get this? Or am I doing something wrong?