Skip to content

Instantly share code, notes, and snippets.

@tim-phillips
Last active September 10, 2020 21:12
Show Gist options
  • Save tim-phillips/7cda2f67f578dcde40fe68eaedfe9236 to your computer and use it in GitHub Desktop.
Save tim-phillips/7cda2f67f578dcde40fe68eaedfe9236 to your computer and use it in GitHub Desktop.
Converts ISO 8601 date string to human readable date string
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