title: Why is mongoose changing date attributes's value?
body: <p>I have a Model that has a date attribute, I'm getting it's value from a post request. I have at least two problems: </p>
  
  <ol>
  <li>Mongoose is accepting this input as a date : <code>19124-012-030</code></li>
  <li>When I send only the year Mongoose fills the month and day and changes the year value.</li>
  </ol>
  
  <p>I haven't tried anything yet, I don't have any validation in my schema, I'm relying only on the type proprety (<code>type: Date</code>)</p>
  
  <p><strong>Schema</strong>:</p>
  
  <pre><code>const mySchema = mongoose.Schema({
      ...
      date: {
       type: Date
      },
  });
  </code></pre>
  
  <p><strong>Form</strong>:</p>
  
  <pre><code>&lt;input id="dat" type="text" name="date" placeholder="date (yyyy-mm-dd)"&gt;
  </code></pre>
  
  <p><strong>Route handler</strong>:</p>
  
  <pre><code>app.post("/api/exercise/add", function(req, res, next) {
      User
       .findById(req.body.userId)
       .exec()
       .then(function(user) {
         return Promise.all([user, new Exercise({
           description: req.body.description,
           duration: req.body.duration,
           date: req.body.date, //BUG: must add validations
           user: user
         }).save()]);
       })
       .then(function([user, exercise]) {
          user.exercises.push(exercise);
          return user.save();
       })
       .then(user =&gt; res.json({ status: 201, exercises: user.exercises }))
       .catch(err =&gt; next(err))
       });
  </code></pre>
  
  <p>(1)The expected output of <code>19124-012-030</code> is to raise an error, instead the object gets persisted with : <code>19124-12-29T23:00:00.000+00:00</code>
  (2)When the input is only <code>11111</code> the object is persisted with : <code>11110-12-31T23:00:00.000+00:00</code></p>
  
  <p><strong>Update</strong>
  The issue  is on. I have not found anything similar. Nothing is provided in MongoDB's documentation to help understand the problem.</p>