我将moment.js
用于我的本机项目日期时间格式化程序。我想从utc日期中删除时区。对于我的时区是GMT + 8000,所以对于utc偏移量是正确的,当我添加format('YYYY/MM/DD 00:00')
时,结果减去一天。
console.log(moment.utc());
-> Moment {_isAMomentObject: true, _isUTC: true, _pf: {…}, _locale: Locale, _d: Wed Jul 11 2018 11:08:57 GMT+0800 (Malaysia Time), …}
console.log(moment.utc().utcOffset(new Date().getTimezoneOffset()));
-> Moment {_isAMomentObject: true, _isUTC: true, _pf: {…}, _locale: Locale, _d: Wed Jul 11 2018 03:08:57 GMT+0800 (Malaysia Time), …}
console.log(moment.utc().utcOffset(new Date().getTimezoneOffset()).format('YYYY/MM/DD 00:00'));
-> "2018/07/10 00:00"
任何想法如何?还是我做错了?