Skip to content

Instantly share code, notes, and snippets.

@mohokh67
Created June 1, 2020 14:26
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohokh67/e0c5035816f5a88d6133b085361ad15b to your computer and use it in GitHub Desktop.
Save mohokh67/e0c5035816f5a88d6133b085361ad15b to your computer and use it in GitHub Desktop.
Get YYYY-MM-DD HH-MM-SS in JavaScript
const formatedTimestamp = ()=> {
  const d = new Date()
  const date = d.toISOString().split('T')[0];
  const time = d.toTimeString().split(' ')[0].replace(/:/g, '-');
  return `${date} ${time}`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment