How to format the datetime in the raw query, my database is mysql. The format i want is YYYY-MM-DD HH:mm:SS
, but now it is YYYY-MM-DDTHH:mm:ss:000Z
.
In defaults option, Sequelize return UTC format.
If you want to change it to YYYY-MM-DD HH:mm:ss
add dateStrings: true
in dialectOptions
example :
const options = {
host: process.env.MYSQL_HOST,
port: process.env.MYSQL_PORT,
dialectOptions: {
dateStrings: true
}
logging: true
};
const sequelize = new Sequelize(process.env.MYSQL_NAME, process.env.MYSQL_USER, process.env.MYSQL_PASS, options);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.