I'm trying to convert unix timestamp to local date in a react project. Below is the function that I'm using:
function convertDate(unixDate) {
const d = new Date(unixDate * 1000);
const day = d.toLocaleString(d.getDate())
return(day);
}
The date I'm getting is not acurate. For example is we run convertDate(1657745369979.82) we should get the date '07/13/2022 8:49:29 PM'. However the date that I'm actually getting is '11/10/54501, 8:59:39 AM'