草庐IT

futureMonth

全部标签

javascript - 如何在 moment.js 中正确地将 1 个月添加到当前日期

我在moment.js的文档中读到,如果你想在当前日期上增加1个月,你可以使用这个代码:varmoment=require('moment');varfutureMonth=moment().add(1,'M').format('DD-MM-YYYY');但问题是这并没有像我期望的那样添加。例如,假设当前日期是2015年10月31日(10月的最后一天)。在代码中:varcurrentDate=moment().format('DD-MM-YYYY');varfutureMonth=moment().add(1,'M').format('DD-MM-YYYY');console.log(

javascript - 如何在 moment.js 中正确地将 1 个月添加到当前日期

我在moment.js的文档中读到,如果你想在当前日期上增加1个月,你可以使用这个代码:varmoment=require('moment');varfutureMonth=moment().add(1,'M').format('DD-MM-YYYY');但问题是这并没有像我期望的那样添加。例如,假设当前日期是2015年10月31日(10月的最后一天)。在代码中:varcurrentDate=moment().format('DD-MM-YYYY');varfutureMonth=moment().add(1,'M').format('DD-MM-YYYY');console.log(