So This is my first time using Moment.js and I encountered the following problem, so I have this following dates:
now: 2017-01-26T14:21:22+0000
expiration: 2017-01-29T17:24:22+0000
What I want to get is:
Day: 3
Hours: 3
Mins: 3
I tried the following code:
const now = moment();
const exp = moment(expire_date);
console.log(expire_date);
days = exp.diff(now, 'days');
hours = exp.diff(now, 'hours') - (days * 24);
minutes = exp.diff(now, 'minutes') - ((days * 1440) + (hours * 24) * 60);
I know I did something wrong (maybe my calculation or I used the wrong method), but I can't figure out what it is.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…