Sequelize set timezone to query

Danis picture Danis · Feb 22, 2018 · Viewed 13.3k times · Source

I'm currently using the Sequelize with postgres in my project. I need to change the query, so it return created_at column with timezone offset.

var sequelize = new Sequelize(connStr, {
dialectOptions: {
    useUTC: false //for reading from database
},
timezone: '+08:00' //for writing to database

});

But this affects on entire database. But I need to use timezone for select queries only. Does anyone know how to do that?

Answer

Developerium picture Developerium · Apr 18, 2019

This is how I configured it:

  dialectOptions: {
    dateStrings: true,
    typeCast: true,
  },
  timezone: 'America/Los_Angeles',

http://docs.sequelizejs.com/class/lib/sequelize.js~Sequelize.html