title: How to prevent Sequelize from converting Date object to local time
body: <p>I am using <a href="https://github.com/sequelize/sequelize" rel="nofollow noreferrer">sequelize</a> for a node project. It's connecting to a Postgres databsae, which contains a table with a <code>DATE</code> field (unlike <code>TIMESTAMP WITH TIMEZONE</code>, <code>DATE</code> has not time data).</p>
  
  <p>In the code I'm modeling the date using a javascript <code>Date</code> object, which stores the time as UTC midnight. When I use that to insert a record into the table using that <code>Date</code> object, sequelize is apparently coverting it to local time first because the records are always 1 day behind. So if I want to insert 2000-10-31 into the database I end up with 2000-10-30. I am in UTC-5.</p>
  
  <p>How do I tell sequelize to not convert the Date to a local time before inserting into the database?</p>
  
  <p>Here is some sample code. I also created a <a href="https://github.com/dland512/sequelize-date-issue" rel="nofollow noreferrer">repository</a> if you want to run it yourself.</p>
  
  <pre><code>var Sequelize = require('sequelize');
  
  const sequelize = new Sequelize('testdb', 'postgres', '???', {
      host: 'localhost',
      dialect: 'postgres'
  });
  
  TestTable = sequelize.define('date_test',
      {
          id: {
              primaryKey: true,
              type: Sequelize.INTEGER,
              autoIncrement: true
          },
  
          someDate: {
              field: 'some_date',
              type: Sequelize.DATEONLY
          }
      },
      {
          timestamps: false,
          freezeTableName: true
      }
  );
  
  // midnight UTC on Halloween 
  var date = new Date(Date.UTC(2000, 9, 31));
  
  // converts to local time resulting in 2000-10-30
  TestTable.create({ someDate: date })
      .then(function() {
          // also apparently converts to local time resulting in 2000-10-30
          return TestTable.create({ someDate: date.toUTCString() });
      })
      .then(function() {
          // convert to string, definitely works but seems unnecessary
          var strDate = date.getUTCFullYear() + '-' + pad2(date.getUTCMonth() + 1) + '-' + pad2(date.getUTCDate());
          return TestTable.create({ someDate: strDate });
      })
      .then(function() {
          // cerate a new local Date, also works but seems hacky
          var newDate = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
          return TestTable.create({ someDate: newDate });
      })
      .then(function() {
          process.exit(0);
      });
  
  
  function pad2(n) {
      if (n.length === 1) {
          return '0' + n;
      }
  
      return n;
  }
  </code></pre>