Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created August 6, 2022 16:11
Show Gist options
  • Save hieptl/7056eb01515d633dfb6bf583f696df46 to your computer and use it in GitHub Desktop.
Save hieptl/7056eb01515d633dfb6bf583f696df46 to your computer and use it in GitHub Desktop.
How to Get the Current Date in Javascript - Format Date (YYYY-MM-DD)
const currentDate = new Date();
const yyyyMMDDDate =
currentDate.getFullYear() +
"-" +
(currentDate.getMonth() + 1) +
"-" +
currentDate.getDate();
console.log(yyyyMMDDDate);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment