I use moment.js in my React application 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 1511638810 (Sat, November 25, 2017 19:40:10 GMT)this.state.saleEndTimeis 1516909110(Thu, 25 January 2018 19:38:30 GMT)
However, he concludes
an hour
This is obviously not correct, it should be 2 months. What have I done wrong?
Using moment v2.19.2 with node v7.9.0
Edit: The output should be humanize'ed, and the time difference between this.state.saleStartTimeand this.state.saleEndTimecan vary from minutes to several months ...
source
share