0

我将销售日期作为 UTC 存储在 mysql 表的 TIMESTAMP 列中。

世界各地的用户需要在其基于时区的设置中显示销售额

如何使用 mysql2 npm 包为每个用户请求设置时区?

4

1 回答 1

0

You can use CONVERT_TZ in your sql request like this:

//CONVERT_TZ (dt, from_tz,to_tz)
SELECT CONVERT_TZ('2008-05-15 12:00:00','+00:00','+10:00') as required_datetime";

for details visite the link CONVERT_TZ

For information I prefer to use moment.js

于 2020-05-19T08:57:19.850 回答