title: Error when trying to add timestamps to comment section for social media web app using firebase
body: <p>When trying to setup timestamps for a comment system for users on my social media web app I get the error:</p>
  <p>&quot;TypeError: firebase__WEBPACK_IMPORTED_MODULE_4__[&quot;default&quot;].firestore.FieldValue.serverTimeStamp is not a function. (In 'firebase__WEBPACK_IMPORTED_MODULE_4__[&quot;default&quot;].firestore.FieldValue.serverTimeStamp()', 'firebase__WEBPACK_IMPORTED_MODULE_4__[&quot;default&quot;].firestore.FieldValue.serverTimeStamp' is undefined)&quot;</p>
  <p>This is the section of code where the errors are coming from:</p>
  <pre><code>    const postComment = (event) =&gt; {
      event.preventDefault();
  
      db.collection(&quot;posts&quot;).doc(postId).collection(&quot;comments&quot;).add({
          text: comment,
          username: username.displayName,
          timestamp: firebase.firestore.FieldValue.serverTimeStamp(),
      });
      setComment('');
  }
  </code></pre>
  <p>If anyone can help I would greatly appreciate it.</p>
  <p>screenshot:</p>
  <p>![screenshot] (<a href="https://cdn.glitch.com/0f2dd307-0d28-4fe9-9ef9-db84277033dd%2FScreenshot%202021-07-18%20at%2011.36.14.png?v=1626604625641" rel="nofollow noreferrer">https://cdn.glitch.com/0f2dd307-0d28-4fe9-9ef9-db84277033dd%2FScreenshot%202021-07-18%20at%2011.36.14.png?v=1626604625641</a>)</p>