转换数据和时间

问题描述 投票:0回答:2

想要从日期+时间中删除TimeZone详细信息。(EmberJS)

输入:“2019-03-11T09:00:00.000 + 09:00”(GMT + 9)。

喜欢转换为格式“2019-03-11T09:00:00.000 + 00:00”(GMT + 0)

使用案例:API返回:qazxsw poi

UI TimeZone是:timestamp: "2019-03-11T09:00:00.000+09:00"

目前UI显示:UTC+9

用户界面应该显示3/11/2019 18:00

javascript ember.js
2个回答
0
投票

尝试使用3/11/2019 9:00插件

ember-moment

{{moment-format '12-1995-25' 'MM/DD/YYYY' 'MM-YYYY-DD'}}替换为您的API返回日期


0
投票

如果您只想将时区从您收到的日期作为字符串删除,您只需要使用正则表达式删除'+09:00'部分:

12-1995-25

或者,用UTC替换时区:

new Date('2019-03-11T09:00:00.000+09:00'.replace(/(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3})[+\-]\d{2}:\d{2}/, '$1'))

如果你想在时区之间进行转换,你可以使用new Date('2019-03-11T09:00:00.000+09:00'.replace(/(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3})[+\-]\d{2}:\d{2}/, '$1+00:00')) moment-timezone

© www.soinside.com 2019 - 2024. All rights reserved.