Skip to content

Instantly share code, notes, and snippets.

@rijkvanzanten
Created September 12, 2017 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rijkvanzanten/84c71c61cf8fdc4a91e24617cae88486 to your computer and use it in GitHub Desktop.
Save rijkvanzanten/84c71c61cf8fdc4a91e24617cae88486 to your computer and use it in GitHub Desktop.
MySQL date to JS
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