Skip to content

Instantly share code, notes, and snippets.

@jdelafon
Created March 13, 2017 10:16
Show Gist options
  • Save jdelafon/e84428c468f7205f2f3121a1df64f1fd to your computer and use it in GitHub Desktop.
Save jdelafon/e84428c468f7205f2f3121a1df64f1fd to your computer and use it in GitHub Desktop.
JS current timestamp
// Compatible with java.sql.Timestamp/MySQL
(new Date (
(new Date((new Date(new Date())).toISOString())).getTime()
- ((new Date()).getTimezoneOffset()*60000)
)).toISOString().slice(0, 19).replace('T', ' ');
// "2017-03-13 11:08:56"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment