[英]Invalid Date error on moment.js
this is my code 这是我的代码
moment("14/5/2015 5:52 am")
I don't know why invalid code error was come.How can i solve this issue? 我不知道为什么会出现无效代码错误。如何解决此问题?
For this case, you need to supply the format too: 对于这种情况,您还需要提供格式:
var m = moment("14/5/2015 5:52 am", 'DD/MM/YYYY h:mm a')
Then it works as expected: 然后它按预期工作:
> m.date()
14
> m.month()
4
> m.year()
2015
Thanks @Daemedeor 谢谢@Daemedeor
I found the answer from your comment. 我从您的评论中找到了答案。
Now i have changed my date format to Month first then date 现在,我先将日期格式更改为月,然后将日期更改为
Like something below, 像下面的东西
moment("5/14/2015 5:52 am")// Now its' working.
Thanks!! 谢谢!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.