gpt4 book ai didi

javascript - 日期格式在 momentjs 中不起作用?

转载 作者:行者123 更新时间:2023-11-28 19:11:36 27 4
gpt4 key购买 nike

以下日期格式在 momentJs 中不起作用

 var date ="01-12-2015";//DD-MM-YYY
console.info(moment(date).format('YYYY-MM-DD'));

我该如何解决这个问题?

最佳答案

你需要告诉 momentJS 如何解析你给出的字符串:

var date ="01-12-2015";//DD-MM-YYYY
console.info(moment(date, 'DD-MM-YYYY').format('YYYY-MM-DD'));

Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.

关于javascript - 日期格式在 momentjs 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30641910/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com