Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sequelize set timezone to query

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?

like image 262
Danis Avatar asked Feb 22 '18 16:02

Danis


Video Answer


1 Answers

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

like image 116
Developerium Avatar answered Oct 19 '22 14:10

Developerium