当前位置: 首页 > Web前端 > HTML

nods中mysql的时差是8小时

时间:2023-03-28 12:50:39 HTML

前言最近在做自己的一个记账项目,后端nestjs使用的是typeorm的mysql。添加记录时,发现时差8小时。后来查了资料,发现默认时区是UTC。所以只需将其设置为我们自己的时区即可。解决方案ormconfig.json{"type":"mysql","host":"localhost","port":3306,"username":"","password":"","database":"development","entities":["dist/**/*.entity{.ts,.js}"],"synchronize":true,"timezone":"+08:00"//添加这个}