Created
May 19, 2021 14:58
-
-
Save caroillemann/8a1147f0d91b04971ab7b6a4a9d39321 to your computer and use it in GitHub Desktop.
Snippets for date formatting
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
// 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