Reputation: 485
So, I'm using moment.js to calculate number of days between the current date and a given date and it returns something like "a month ago" or "5 days ago". I want it to just return "30" or "5" instead.
import moment from "moment";
console.log(moment("2018-09-01", "YYYY-MM-DD").fromNow())
Upvotes: 0
Views: 102
Reputation: 1822
You can do this.
console.log(moment().diff(moment("2018-09-01"), "days"))
Upvotes: 3