0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Updated dateString method to use cleaner toLocaleDateString (#144)

no refs

- Updates `getDateString` method to use `toLocaleDateString` which is cleaner and shorter with same result
This commit is contained in:
Joakimk 2021-06-20 10:00:46 +02:00 committed by GitHub
parent df54d8cf34
commit b80ab90d61

View file

@ -1,7 +1,5 @@
export const getDateString = (isoDate) => {
const date = new Date(isoDate);
const month = date.toDateString().substring(4, 7);
const day = date.toDateString().substring(8, 10).replace(/^0+/g, '');
const year = date.toDateString().substring(11, 15);
return `${day} ${month} ${year}`;
const event = new Date(isoDate);
const options = { year: 'numeric', month: 'short', day: 'numeric' };
return event.toLocaleDateString('en-GB', options);
};