I have an epoch time which I've converted to DD/MM/YYYY, and I've then converted that into a long date.
However, the format I want is "Mon Sept 06 2021", but I'm getting "Mon Sep 06 2021 00:00:00 GMT+0100 (British Summer Time)"
How can I remove everything after the year? Is it due to the Date constructor?
convertDate = (epoch) => {
const getDate = new Date(epoch * 1).toLocaleDateString();
console.log(getDate);
const [dateComponents] = getDate.split(" ");
console.log(dateComponents);
const [day, month, year] = dateComponents.split("/");
const date = new Date(+year, month - 1, +day);
console.log(date);
return date;
};