Instantiate **new Date()** to get the current date and time, or use **new Date().toISOString().split(“T”)[0]`** (or local date getters) to get today’s date string cleanly.
Get Today’s Date Object & Formatted String
const today = new Date();
// Local readable format (e.g., "11/19/2026" or regional equivalent)
console.log(today.toLocaleDateString());
// Local YYYY-MM-DD format (avoids UTC timezone date shifts)
const localDate = [
today.getFullYear(),
String(today.getMonth() + 1).padStart(2, "0"),
String(today.getDate()).padStart(2, "0")
].join("-");
console.log(localDate); // "2026-11-19" '
You must log in or register to comment.
