I am trying to change the subtract date format by this javascript code but i want it should print day name for example "Sunday". currently it's printing Wed "Jan 30 2019 02:31:30 GMT+0600 (Bangladesh Standard Time)"
var el_up = document.getElementById("GFG_UP");
var el_down = document.getElementById("GFG_DOWN");
var today = new Date();
el_up.innerHTML = "Today's date = " + today;
Date.prototype.subtractDays = function(d) {
this.setTime(this.getTime() - (d * 24 * 60 * 60 * 1000));
return this;
}
function gfg_Run() {
var a = new Date();
a.subtractDays(4);
el_down.innerHTML = a;
}
<h1 style="color:green;">
GeeksForGeeks
</h1>
<p id="GFG_UP" style="font-size: 15px; font-weight: bold;">
</p>
<button onclick="gfg_Run()">
subtractDays
</button>
<p id="GFG_DOWN" style="color:green; font-size: 20px; font-weight: bold;">
</p>
How can I convert it?