【发布时间】:2022-01-16 19:34:38
【问题描述】:
我有将本地时间转换为 UTC 时间的功能,它在本地工作正常,但是当我在 aws 上部署应用程序时,它不再工作
import timezone from "geo-tz";
import moment from "moment-timezone";
const { find } = timezone;
function convertToUtc(time, lon, lat) {
const timezone = find(lat, lon);
const date = moment(time, "HHmm").tz(timezone[0]).utc().format("HH:mm");
return date;
}
export default convertToUtc;
这就是我使用这个模块的地方
const user = await User.find({ chatID: res.chat.id });
const utctime = utc(
user[0].time,
res.location.longitude,
res.location.latitude
);
await User.find({ chatID: res.chat.id }).update({
time: utctime,
location: res.location,
});
【问题讨论】:
标签: node.js amazon-ec2 momentjs