年龄计算返回错误结果

时间:2019-03-31 19:18:16

标签: javascript momentjs

我正在使用momentJS来获取孩子的年龄:

const current = new Date(1529013600000) // 15.06.2018
const birthday = new Date(1492207200000) // 15.04.2017
const now = moment(current)
const { _data: { days, months, years } } = moment.duration(now.diff(birthday))

我希望得到1年2个月的结果,但是我确实得到1年1个月的结果。我在做什么错了?

0 个答案:

没有答案