'Sort dates in Reactjs using Moment?
How to sort dates in Reactjs with the moment formatter? Tried this code and wont work
const sortByDate = (d1,d2) => {
new Date(b).getTime() - new Date(a).getTime()
}
dateFormat = (firstDate, lastDate) => {
let first = moment(new Date(firstDate).format("YYYY-MMM-DD")
let last = moment(new Date(lastDate).format("YYYY-MMM-DD")
}
return (sortByDate(first) + " - " + last)
Expected output should be like this
2022-01-01 - 2022-01-31
2022-02-01 - 2022-02-31
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
