[英]Parsing datestring in format “dd/mm/yyyy” in moment.js
I can't parse the simplest date string for some reason. 由于某种原因,我无法解析最简单的日期字符串。 the following is giving me 'invalid date'. 以下是给我“无效日期”。
moment.locale('en-gb');
var tempDate = moment("23/07/2018").format("DD/MM/YYYY");
this doesn't work either: 这也不起作用:
moment.locale('en-gb');
var tempDate = moment("23/07/2018");
您可以使用moment
函数的String + Format版本:
moment("23/07/2018", "DD/MM/YYYY")
var mydate= moment("23/07/2018","DD/MM/YYYY").format("DD/MM/YYYY"); console.log(mydate);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.