You can format the date in JS by using the toLocaleDateString function.

It accepts a locale and returns a string with formatted date.

Let’s try to use the locale en-US.

const now = new Date();

console.log(now.toLocaleDateString('en-US'));  // 1/17/2022

If you’re looking to add time, you can use the method toLocaleString, which works similarly.

const now = new Date();

console.log(now.toLocaleString('en-US'));  // 1/17/2022, 3:15:04 PM