简体   繁体   中英

Invalid Date moment.js using Iso yyyy-MM-dd HH:mm:ss

I have a date in the format yyyy-MM-dd HH:mm:ss that I am using to create moments for x axes values in chart.js I get invalid date when I am newing up an instance of the moment.js class

在此处输入图片说明

$.each(unique, function (index, value) {                    
                var momentDate = moment(value, "DD MMM YY HH:mm:ss");
                momentsArray.push(momentDate);
            });

I have read the documentation and I believe I am following the right ISO format for creating moment.js object. What I am doing wrong ?

根据您的日期值"2020-10-19 15:50:20" ,您的格式字符串应为"YYYY-MM-DD HH:mm:ss"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM