如何将日期格式化为moment.js隔离日期?

时间:2017-10-30 12:50:37

标签: momentjs

此代码正常运行:

var start = moment([2017, 10, 5]);
var end   = moment([2017, 10, 10]);
var result = end.from(start); 

console.log(result)
<script src="https://momentjs.com/downloads/moment-with-locales.min.js"></script>

使用此代码,我希望得到与上面代码相​​同的结果:

var start_input = "05.10.2017";
var end_input= "10.10.2017";

var start = moment(start_input, 'DD.MM.YYYY').toDate();
var end = moment(end_input, 'DD.MM.YYYY').toDate();
var result = end.from(start); 

console.log(result)
<script src="https://momentjs.com/downloads/moment-with-locales.min.js"></script>

但是有一个错误......

0 个答案:

没有答案