I have an array of dates like this
arr = ["2018-08-01T15:16:34.791Z","2018-08-01T15:16:34.791Z","2018-08-
01T15:16:34.791Z"]
So I tried converting those dates to time:
convertedArr = arr.map( payment => {
var converted
converted = new Date(payment.date_updated).getTime()
return converted
})
-And then sort them out and get the highest amount of time through another function:
getLatestPayment(convertedArr){
const sortFromHighest = arr => {
return arr.sort( (a,b) => { return a < b } )
}
var convertedArr = convertedArr
convertedArr = sortFromHighest(convertedArr)
convertedArr = convertedArr.map( elem =>{
new Date(elem)
})
return paymentsArr[0]
}
Then I get an undefined value after that because I can't do this convert the dates from time back to dates again, is there an actual way to make to get the dates from time? or perhaps a different solution? thanks in advance