2019-08-02 moment.js使用之坑

如题所述

第1个回答  2022-06-23
使用moment.js设定一个固定的日期,同事小白写了一个moment(2018/01/01),结果控制台报出

value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release

google翻译:

提供的值不是公认的RFC2822或ISO格式。 时刻构造回落到js Date(),这在所有浏览器和版本中都不可靠。 不鼓励使用非RFC2822 / ISO日期格式,并将在即将发布的主要版本中删除.

原因是设置格式不正确,moment(20180101)!   领教了,兄弟。
相似回答