Skip to content

Instantly share code, notes, and snippets.

@gitSambhal
Created June 8, 2018 05:48
Show Gist options
  • Save gitSambhal/c131333fc466c12c4d7bdbdcc00e717a to your computer and use it in GitHub Desktop.
Save gitSambhal/c131333fc466c12c4d7bdbdcc00e717a to your computer and use it in GitHub Desktop.
Convert JS date time to MySQL datetime
var formatedMysqlString = (new Date ((new Date((new Date(new Date())).toISOString() )).getTime() - ((new Date()).getTimezoneOffset()*60000))).toISOString().slice(0, 19).replace('T', ' ');
console.log( formatedMysqlString );
@gitSambhal
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment