Wednesday, 11 April 2018

How to convert a date in dd-MMM-yyyy in jquery

var monthArr = new Array("Jan", "Feb", "Mar",
"Apr", "May", "Jun", "Jul", "Aug", "Sep",
"Oct", "Nov", "Dec");

        var d = new Date("2018-01-01");
        var cdate = d.getDate();
        var cmonth = d.getMonth();
        var cyear = d.getFullYear();
        alert(cdate + "-" +monthArr [ cmonth]
        + "-" + cyear);

No comments:

Post a Comment