How to format a JavaScript date -


how can format javascript date object print "10-aug-2010"?

function formatdate(date) {    var monthnames = [      "january", "february", "march",      "april", "may", "june", "july",      "august", "september", "october",      "november", "december"    ];      var day = date.getdate();    var monthindex = date.getmonth();    var year = date.getfullyear();      return day + ' ' + monthnames[monthindex] + ' ' + year;  }    console.log(formatdate(new date()));  // show current date-time in console

you can edit array monthnames use jan, feb, mar, etc..


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -