I have found examples for displaying date but I need it in a specific format, ie: 15 Jun 2018, but the months are shortened
[Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
So need it to display todays date in the above format.
var monthShortNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
];
function dateFormat2(d) {
var t = new Date(d);
return t.getDate() + ' ' + monthShortNames[t.getMonth()] + ', ' + t.getFullYear();
}
//console.log(dateFormat2(new Date()))
var showDate = dateFormat2(new Date())
document.getElementById("todays-date").innerHTML = showDate + 14:44;
Then trying to output it in a div here:
<div id="todays-date"></div>
Can't seem to get it working. If there's a better way please let me know. Thanks