0
function loadTable() { //function 
    var reportedFromDate = document.IssueForm.reportedFromDate.value; //getting value from input field
    alert(reportedFromDate); //displays dd-mm-yy 31-02-13
}

I want to convert it as 31-FEB-13

2
  • What have you tried? You'll likely need a table of month name abbreviations. Then it's easy, and you don't even need jQuery. Commented Mar 18, 2013 at 7:31
  • 1
    webdevelopersnotes.com/tips/html/… Commented Mar 18, 2013 at 7:32

2 Answers 2

1

check following snippet :

  function loadTable() { //function 
        var reportedFromDate = document.IssueForm.reportedFromDate.value; 
        alert(reportedFromDate);  // your format
        var parts=reportedFromDate.split("-");
        var date=parts[0];
        var month=parts[1];
        var year=parts[2];

        var mon=["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEPT","OCT","NOV","DEC"];
        var m=parseInt(month);
        alert( date +"-"+mon[m-1]+"-"+year); // required format
    }
Sign up to request clarification or add additional context in comments.

Comments

0

You need to follow some steps:

1. Create one array of months like 
var months = ["JAN","FEB"....,"DEC"];
2. Split the date with (-) seperator
3. Take the 1st index (not 0) and search through the Array (months)
4. Display the formatted date.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.