Created
September 12, 2017 19:33
-
-
Save rijkvanzanten/84c71c61cf8fdc4a91e24617cae88486 to your computer and use it in GitHub Desktop.
MySQL date to JS
This file contains hidden or 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
const parseDate = dateString => { | |
const match = dateString.match(/^(\d+)-(\d+)-(\d+) (\d+)\:(\d+)\:(\d+)$/) | |
match[2] = match[2] - 1; // Month must be 0...11 instead of 1...12 | |
match.shift(); | |
return new Date(...match); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment