时刻能提供这种便利吗?
如果我有两个日期,我能否从一个可以解构以下信息的时刻得到一个对象:
<body onload="functionToBeExecutedAfterPageLoads();">
答案 0 :(得分:1)
是的,您可以使用durations。像这样:
const theDiffObject = {
years: moment.duration(timeDiff).years(),
months: moment.duration(timeDiff).months(),
weeks: moment.duration(timeDiff).weeks(),
days: moment.duration(timeDiff).days()
}