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
答案 0 :(得分:2)
您的解析格式似乎有错误。
const notification = moment(weekDay + " " + time, "DD/HH/YYYY HH:mm");
应该是
const notification = moment(weekDay + " " + time, "DD/MM/YYYY HH:mm");