Skip to content

Instantly share code, notes, and snippets.

@xeniode
Last active March 24, 2020 16:32
Show Gist options
  • Save xeniode/0ba585dc9c8ea04c3e65a5ee97091f2e to your computer and use it in GitHub Desktop.
Save xeniode/0ba585dc9c8ea04c3e65a5ee97091f2e to your computer and use it in GitHub Desktop.
[JS-Current Date Time Func] #javascript #datetime
export function getCurrentDate(separator=''){
let newDate = new Date()
let date = newDate.getDate();
let month = newDate.getMonth() + 1;
let year = newDate.getFullYear();
return `${year}${separator}${month<10?`0${month}`:`${month}`}${separator}${date}`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment