Skip to content

Instantly share code, notes, and snippets.

@nhattruongniit
Created December 10, 2022 03:10
Show Gist options
  • Select an option

  • Save nhattruongniit/1a5577e6b02a8372c155dd7d23d7fb40 to your computer and use it in GitHub Desktop.

Select an option

Save nhattruongniit/1a5577e6b02a8372c155dd7d23d7fb40 to your computer and use it in GitHub Desktop.
getDateTimeStringForFileName
export default function () {
const date = new Date();
const getDay = `0${date.getDate()}`.slice(-2).toString();
const getMonth = `0${date.getMonth() + 1}`.slice(-2).toString();
const getYear = date.getFullYear().toString();
const getHours = `0${date.getHours()}`.slice(-2).toString();
const getMinutes = `0${date.getMinutes()}`.slice(-2).toString();
const getSeconds = `0${date.getSeconds()}`.slice(-2).toString();
return `${getYear}-${getMonth}-${getDay} ${getHours}${getMinutes}${getSeconds}`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment