问题:
Using Moment.js I can't transform a correct moment object to a date object with timezones. 使用Moment.js,我无法将正确的矩对象转换为具有时区的日期对象。 I can't get the correct date. 我找不到正确的日期。
Example: 例:
var oldDate = new Date(),
momentObj = moment(oldDate).tz("MST7MDT"),
newDate = momentObj.toDate();
console.log("start date " + oldDate)
console.log("Format from moment with offset " + momentObj.format())
console.log("Format from moment without offset " + momentObj.utc().format())
console.log("(Date object) Time with offset " + newDate)
console.log("(Date object) Time without offset "+ moment.utc(newDate).toDate())
解决方案:
参考一: https://stackoom.com/question/1DTPL/Moment-js转换为日期对象参考二: https://oldbug.net/q/1DTPL/Moment-js-transform-to-date-object
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/4377080