【问题标题】:MomentJs gives wrong monthMomentJs 给出错误的月份
【发布时间】:2019-04-04 00:49:37
【问题描述】:

Momentjs 给出错误的月份。

const time = moment("2300","hhmm").format("HH:mm");
const weekDay = moment().weekday(2).format("DD/MM/YYYY");
const notification =  moment(weekDay + " " + time, "DD/HH/YYYY HH:mm");
console.log(notification);

给:

Object
_a: [2018, 0, 30, 23, 0, 0, 0] (7)
_d: Tue Jan 30 2018 23:00:00 GMT+0200 (EET)
_f: "DD/HH/YYYY HH:mm"
_i: "30/10/2018 23:00"
_isUTC: false
_l: undefined

不正确的应该是 2018 年 10 月 30 日星期二 23:00:00 GMT_0200 (EET)

我不明白为什么会出现 Jan 月份。

时刻版本:^2.1.0

【问题讨论】:

标签: javascript angular time ionic2 momentjs


【解决方案1】:

您的解析格式似乎有错误。

const notification = moment(weekDay + " " + time, "DD/HH/YYYY HH:mm");

应该是

const notification = moment(weekDay + " " + time, "DD/MM/YYYY HH:mm");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-08
    • 1970-01-01
    • 2020-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-11
    相关资源
    最近更新 更多