使用Moment.js我无法将正确的时刻对象转换为具有时区的日期对象。我无法获得正确的日期。
示例:
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())