我想转换"2020-09-07T00:52:26.000Z"为07-09-2020 14:22:26,但在转换时我没有得到所需的时间。需要转换:Asia/Kolkata 到 Asia/Hong_Kong我试过:const moment = require('moment-timezone');var momentmm = moment("2020-09-07T00:52:26.000Z").utc();var updatetimezone = moment.tz(momentmm, 'Asia/Hong_kong').format();console.log("1. After Convert timezone", updatetimezone)结果:1.转换时区后 2020-09-07T08:52:26+08:00var str = moment("2020-09-07T00:52:26.000Z").tz('Asia/Hong_kong').utc().format('DD-MM-YYYY HH:mm:ss');console.log("2. After Convert timezone", str)结果:2.转换时区后 07-09-2020 00:52:26期望的结果:07-09-2020 14:22:26
1 回答
ibeautiful
TA贡献1993条经验 获得超5个赞
var on = new Date("2020-09-07T00:52:26.000Z");
var m = moment(on)
var str = moment(m).format('DD-MM-YYYY HH:mm:ss ZZ');
console.log(str)
console.log("Converted timezone", moment.tz(str, 'Asia/Hong_Kong').format('DD-MM-YYYY HH:mm:ss'))
那会做到的..
添加回答
举报
0/150
提交
取消