title: Javascript - How to subtract months from Firebase Firestore Timestamp?
body: <p>How to subtract date from <code>admin.firestore.FieldValue.serverTimestamp()</code>?</p>
  
  <p>Let's say I want to know the date 5 months ago.</p>
  
  <p>By using the <code>new Date()</code> Javascript object, I get the date in  milliseconds.</p>
  
  <p>I would like to save it though as a timestamp in my Firestore Database. How can I accomplish that?</p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>I use this function to discover the date: </p>
  
  <pre><code>function findBirthdate(age){
      var monthsAgo; 
      switch(age){
         case "_6months":
             monthsAgo = 3;
             break;
         case "6_12months":
             monthsAgo = 9;
             break;
         case "12_18months":
             monthsAgo = 15;
             break;
         case "18_24months":
             monthsAgo = 21;
             break;
         case "24_months":
             monthsAgo = 28;
             break;
         default:
             return;
     }
  
     var now = new Date();
     return now.setMonth(now.getMonth() - monthsAgo);
  }
  </code></pre>
  
  <p>So, I call <code>var birth = findBirthdate(age)</code> and send <code>birth</code> to Firestore as in </p>
  
  <p><code>admin.firestore()....update({ birthdate: birth }).then(...</code></p>