Search code examples
javascriptdatedate-format

Custom date format in javascript form date format yyyy-mm-dd


I have the date 2013-03-10 how can i get March 10,2013. I tried a lot with Date function in javascript but can't get correct format as given above.Help should be appreciated.


Solution

  • You can use Date.toLocaleString :

    var options = { month: 'long', day: 'numeric', year: 'numeric' }
    
    console.log( new Date('2013-03-10').toLocaleString('en-US', options) )