简体   繁体   English

使用 Iso yyyy-MM-dd HH:mm:ss 的无效日期 moment.js

[英]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我有一个格式为 yyyy-MM-dd HH:mm:ss 的日期,我用它来为 chart.js 中的 x 轴值创建矩我在新建 moment.js 类的实例时得到无效日期

在此处输入图片说明

$.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.我已阅读文档,并且我相信我遵循正确的 ISO 格式来创建 moment.js 对象。 What I am doing wrong ?我做错了什么?

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用moment.js(时区)时以(“ YYYY-MM-DD HH:mm”)格式返回日期和时间 - Return date and time in (“YYYY-MM-DD HH:mm”) format when using moment.js (timezone) 当日期为MM / DD / YYYY HH:mm:ss时,moment.js从现在的日期返回意外 - moment.js returning an unexpected fromNow date when date is MM/DD/YYYY HH:mm:ss 如何使用moment.js将秒传输到时间格式(YYYY:MM:DD HH:mm:ss) - How to transfer seconds to Time format (YYYY:MM:DD HH:mm:ss) using moment.js 角度js日期过滤器“ yyyy-mm-dd hh:mm:ss”到“ MMM d,yyyy h mm” - Angular js date filter “yyyy-mm-dd hh:mm:ss” to “MMM d, yyyy h mm” 在moment.js中将“ yyyy-mm-ddThh:mm-offset”格式转换为“ yyyy-mm-dd HH:mm” - Convert 'yyyy-mm-ddThh:mm-offset' format to 'yyyy-mm-dd HH:mm' in moment.js Moment.js如何将MM / dd / yyyy HH:mm:ss.fff转换为往返日期/时间模式? - Moment.js How to convert MM/dd/yyyy HH:mm:ss.fff to round-trip date/time pattern? 使用 moment.js 将日期转换为字符串“MM/dd/yyyy” - Using moment.js to convert date to string “MM/dd/yyyy” 如何使用 Javascript 或 jQuery 从 YYYY-MM-DD HH:MM:SS 修剪 HH:MM:SS - How to trim HH:MM:SS from YYYY-MM-DD HH:MM:SS using Javascript or jQuery 如何使用 NodeJS 将 UTC 日期格式化为“YYYY-MM-DD hh:mm:ss”字符串? - How to format a UTC date as a `YYYY-MM-DD hh:mm:ss` string using NodeJS? 使用Javascript计算两个日期/时间字符串(YYYY-mm-dd HH:MM:SS)之间的小时数 - Calculate Hours Between two Date/Time Strings(YYYY-mm-dd HH:MM:SS) using Javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM