Last active
September 10, 2020 21:12
-
-
Save tim-phillips/7cda2f67f578dcde40fe68eaedfe9236 to your computer and use it in GitHub Desktop.
Converts ISO 8601 date string to human readable date string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertDateToReadableString (date) { | |
if (!date) return | |
const d = new Date(date.replace('-', '/')) | |
return d.toLocaleDateString('en-US', { | |
year: 'numeric', | |
month: 'long', | |
day: 'numeric' | |
}) | |
} | |
assert(convertDate('2018-04-17'), 'April, 17 2018') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment