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:
parent
df54d8cf34
commit
b80ab90d61
1 changed files with 4 additions and 6 deletions
|
@ -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);
|
||||
};
|
Loading…
Add table
Reference in a new issue