title: How can I set correct timezone for a date field in Mongoose?
body: <p>I'm using <strong>moment</strong> for generating time and date:</p>
  
  <pre><code>const moment = require('moment-timezone');
  const emailModel = require('./api/models/emails');
  
  sentTime=moment().tz('America/Los_Angeles').format();
  console.log(sentTime);    //console log  shows correct time
  emailModel.findOneAndUpdate({ _id: emailInfo._id }, {sentTime: sentTime }, { upsert: true },function (err, doc) {
    if (err)
      console.log(err);
  });
  </code></pre>
  
  <p>And this is Schema that I'm using <strong>mongoose</strong> :</p>
  
  <pre><code>const mongoose = require('mongoose');
  
  const Schema = mongoose.Schema;
  const EmailSchema = new Schema({
     .
     .
     .
      sentTime: {
          type: Date,
          trim: true
      }
     .
     .
     .
  });
  </code></pre>
  
  <p>Problem is:
  Console log shows correct time <em>2020-01-07T12:23:00-08:00</em>  BUT mongoose saved incorrect timezone in DB : <em>2020-01-07T20:23:01.000+00:00</em></p>