javascript - Moment.js 格式不正确
问题描述
我正在使用moment.js
我的 react-native 项目日期时间格式化程序。我想从 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"
知道怎么做吗?或者也许我做错了?
解决方案
推荐阅读
- python - 将请求库安装到目标文件夹
- vue.js - 以 vue 组件为 JS 对象构建步骤
- python - 将 SSML 和 Python 与 Azure 语音结合使用
- c# - 关于 tor selenium C#
- windows - 根据源位置中类似名称的文件将文件从一个目录复制到另一个目录
- php - 使用 PHP 将行附加到解析器中的关系
- php - (PHP) CSV 更改列顺序
- javascript - 如何使用 mongoose 库创建自动增量序列
- ssl - javafx 16 WebEngine 异常“SSL 握手失败”
- php - 如何使用 Symfony Mailer 使用动态连接参数发送邮件?