I am trying to generate the current date in the Date Month, Year
format. Currently I am using following code:
function currentDate()
{
var months = [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
];
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
return `${d} ${months[m]}, ${y}`;
}
Although, It's works perfectly. But, is there a shorter way to do this..?
Something like:
(new Date()).format('d M, Y')