const timeStr = '2022-11-04T20:45:35+04:00'
const time = moment(timeStr)
// get the offset from the time string
const offset = timeStr.slice(-6)
// set the timezone offset (so that in case it doesn't match your local time, it's corrected)
time.utcOffset(offset)
// add the offset time, and convert to UTC
time.add(time.utcOffset(), 'minutes').utc()
console.log(time)
1条答案
按热度按时间abithluo1#
我不太确定您的问题的用例是什么,但您可以通过手动调整时区偏移量来实现。
就像这样: