Skip to content

Instantly share code, notes, and snippets.

@caroillemann
Created May 19, 2021 14:58
Show Gist options
  • Save caroillemann/8a1147f0d91b04971ab7b6a4a9d39321 to your computer and use it in GitHub Desktop.
Save caroillemann/8a1147f0d91b04971ab7b6a4a9d39321 to your computer and use it in GitHub Desktop.
Snippets for date formatting
// FIX INVALID DATE STRING
// Purpose: convert invalid date string to a valid one
// Issue: This date string is not valid, so e.g. Safari can't interpret it.
const invalidDateString = '2011-04-12 00:00'
const validDateString = invalidDateString.replace(/-/g, "/")
const date = new Date(validDateString)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment