Skip to content

Instantly share code, notes, and snippets.

@neodigm
Created April 4, 2021 21:38
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 neodigm/fce84b82058270dadd4e5de59d5eedaf to your computer and use it in GitHub Desktop.
Save neodigm/fce84b82058270dadd4e5de59d5eedaf to your computer and use it in GitHub Desktop.
getReadableTS(){. //. Human readable timestamp for automatic file naming
const date = new Date();
const year = date.getFullYear();
const month = `${date.getMonth() + 1}`.padStart(2, '0');
const day =`${date.getDate()}`.padStart(2, '0');
const hour = date.getHours();
const minutes = date.getMinutes();
const seconds = date.getSeconds();
return `${year}${month}${day}_${hour}${minutes}${seconds}`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment