[Solved] Formatting date in Javascript


Use Javascript’s built-in Date methods:

function getDateString() {
    var d = new Date('2014-06-12T23:00:00');   // pass in your date string
    var y = d.getFullYear();  // the full year (4 digits)
    var m = d.getMonth() + 1; // 0-based month

    var dt = d.getDate() + 1;     // 0-based day of the month
    dt = dt < 10 ? '0' + dt : dt; // add a preceding 0 to numbers less than 10      

    var h = d.getHours();     // 0-based hours
    h = h < 10 ? '0' + h : h; // add a preceding 0 to numbers less than 10

    var mn = d.getMinutes();      // minutes
    mn = mn < 10 ? '0' + mn : mn; // add a preceding 0 to numbers less than 10

    return m + "https://stackoverflow.com/" + dt + "https://stackoverflow.com/" + y + ' ' + h + ':' + mn;
}

10

solved Formatting date in Javascript