I am using moment.js in my React app with the following code to find the difference between 2 unix timestamps:
import Moment from 'moment';
Moment.duration(
Moment(this.state.saleEndTime).diff(Moment(this.state.saleStartTime))
).humanize()
where
this.state.saleStartTime
is1511638810
(Sat, 25 Nov 2017 19:40:10 GMT)this.state.saleEndTime
is1516909110
(Thu, 25 Jan 2018 19:38:30 GMT)
However it is giving the output
an hour
This is obviously not correct, it should be 2 months. What did I do wrongly?
Using moment v2.19.2 with node v7.9.0
Edit: Output needs to be humanize
'ed, and the time difference between this.state.saleStartTime
and this.state.saleEndTime
can range from minutes to months...