【问题标题】:Moment is showing wrong date in React NativeMoment 在 React Native 中显示错误的日期
【发布时间】:2020-01-22 15:29:44
【问题描述】:

我正在使用时刻将我的 JSON 日期转换为正常日期格式,但我从正确日期得到了 13 天前的日期。

var dt = Moment.utc('2020-01-15T00:00:00').format('d MMM YYYY');
console.log(dt); // console value: 3 Jan 2020

【问题讨论】:

标签: javascript reactjs react-native momentjs


【解决方案1】:

d 是星期几的格式 (0-6)。您想要 DDD 表示月份中的某天。

Moment docs for format options

【讨论】:

    【解决方案2】:

    根据https://momentjs.com/docs/#/displaying/format/ d 而格式化时刻适用于 (0-6) 的星期几 所以在你的情况下,它显示为一周的第三天

    【讨论】:

      猜你喜欢
      • 2016-05-19
      • 1970-01-01
      • 1970-01-01
      • 2022-10-09
      • 1970-01-01
      • 1970-01-01
      • 2022-01-07
      • 1970-01-01
      • 2020-04-23
      相关资源
      最近更新 更多