Skip to content

Instantly share code, notes, and snippets.

@jeanlucaslima
Created March 21, 2015 03:20
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 jeanlucaslima/63d76aadf209be747135 to your computer and use it in GitHub Desktop.
Save jeanlucaslima/63d76aadf209be747135 to your computer and use it in GitHub Desktop.
MySQL date to JavaScript
// Divide a string em [ Y, M, D, h, m, s ]
var t = "2015-03-21 03:12:01".split(/[- :]/);
// Aplica os itens em uma nova variável, já no padrão de data JavaScript
var d = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment