慕后森
var a = moment([2017, 7, 1]);var b = moment([2017, 7, 3, 12]);var duration = moment.duration(b.diff(a));var m = { hours: `${parseInt(duration.asHours(), 10)}`, minutes: `${parseInt(duration.asMinutes()) % 60}`, seconds: `${parseInt(duration.asSeconds()) % 60}`, toString: function() { let m = `00${this.minutes}`.substr(this.minutes.length); let s = `00${this.seconds}`.substr(this.seconds.length); return `${this.hours}:${m}:${s}`; }};console.log(m.toString());补充:再来个简化点的版本var a = moment([2017, 7, 1]);var b = moment([2017, 7, 3, 12]);var duration = moment.duration(b.diff(a));var s = `${duration.asHours()}:${moment([2000, 1, 1]).add(duration).format("mm:ss")}`;console.log(s);