I have this code that shows the date as "Mar 25 2022" for example. How can modify the code to display a comma between the day number and year? Like this: "Mar 25, 2022"
var d = (new Date()).toString().split(' ').splice(1,3).join(' ');
document.write(d)
You didn't show us the code which is generating this date, and if possible you should fix the format mask there to get the output you want. Assuming you can't do that, here is one terse way of adding the comma:
var date = "Mar 25 2022";
date = date.replace(/(?<=\d) /, ", ");
console.log(date);