From b80ab90d61f1fb07b88e1594de0d2ea2adfda4a9 Mon Sep 17 00:00:00 2001 From: Joakimk Date: Sun, 20 Jun 2021 10:00:46 +0200 Subject: [PATCH] Updated dateString method to use cleaner `toLocaleDateString` (#144) no refs - Updates `getDateString` method to use `toLocaleDateString` which is cleaner and shorter with same result --- ghost/portal/src/utils/date-time.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ghost/portal/src/utils/date-time.js b/ghost/portal/src/utils/date-time.js index e7179a36ac..9e04e4c034 100644 --- a/ghost/portal/src/utils/date-time.js +++ b/ghost/portal/src/utils/date-time.js @@ -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}`; -}; \ No newline at end of file + const event = new Date(isoDate); + const options = { year: 'numeric', month: 'short', day: 'numeric' }; + return event.toLocaleDateString('en-GB', options); +};