You can format a date in JavaScript using toLocaleDateString() Method:
The toLocaleDateString() method returns a string representing the date portion of a Date object, according to locale-specific conventions. It allows for customization through options.
Example:
const date = new Date(2025, 0, 2); // January 2, 2025
// Default locale
console.log(date.toLocaleDateString()); // e.g., "1/2/2025" in en-US
// Specified locale with options
console.log(date.toLocaleDateString('en-GB', {
weekday: 'long', // "Thursday"
year: 'numeric', // "2025"
month: 'long', // "January"
day: 'numeric' // "2"
})); // Output: "Thursday, 2 January 2025"