title: How to send date when submitting a form with Node.js and Express
body: <p>I followed this <a href="https://zellwk.com/blog/crud-express-mongodb/" rel="nofollow noreferrer">tutorial</a> where I can make a form where user submits a comment and name. However, I want to send the date the user presses the submit-button. It seems like it only saves data that user puts into the textfields. I don't want the users to be able do it themselves. How do I do it? </p>
  
  <p>I was using jQuery but changed to Node.js / Express because I had to save the data to a database, and I don't understand it very well.</p>
  
  <p>Code on index.ejs:</p>
  
  <pre><code>  &lt;form action="/tweets" method="POST"&gt;
   &lt;input type="name" id="name" placeholder="name" name="name"&gt;
   &lt;textarea type="text" id="tweet" placeholder="What's up?" name="tweet"&gt;&lt;/textarea&gt;
   &lt;button type="submit"&gt;Tweet!&lt;/button&gt;
   &lt;/form&gt;
  </code></pre>
  
  <p>Whenever I press submit. name and tweets gets saved but I don't know how to save the date. </p>
  
  <p>The .js code is like this:</p>
  
  <pre><code>app.post('/tweets', (req, res) =&gt; {
  db.collection('tweets').save(req.body, (err, result) =&gt; {
   if (err) return console.log(err)
  
  console.log('saved to database')
  res.redirect('/')
  })
  })
  </code></pre>
  
  <p>When I used jQuery I had a button like this in index.html:</p>
  
  <pre><code>&lt;input type="button" id="addTweet" value="Tweet!"/&gt;
  </code></pre>
  
  <p>where in the .js file did it like this:</p>
  
  <pre><code>  $('#addTweet').click(function(){
  var addObj = {
    "name": $('#name').val(),
    "date": getTodayDate(),
    "body": $('#tweet').val()
  }
  </code></pre>
  
  <p>This way I could save the date when they clicked the button. On Node.js I don't understand how/where I can put the date in.</p>