0

How can show date in this format dd/MMM/yyyy using below code

function ToJavaScriptDate(value) {
    debugger;
    var pattern = /Date\(([^)]+)\)/;
    var results = pattern.exec(value);
    var dt = new Date(parseFloat(results[1]));
    debugger;
    return (dt.getMonth() + 1) + "-" + dt.getDate() + "-" + dt.getFullYear();
}
6
  • MMM = 3 letters of month? Commented Aug 21, 2016 at 20:33
  • You ok with jquery-ui? Or only jquery? Commented Aug 21, 2016 at 20:34
  • What exactly is value that you send to the function? Give some examples... Commented Aug 21, 2016 at 20:39
  • date is shown in this format 590104800000 Commented Aug 21, 2016 at 20:42
  • so i use this method to convert it Commented Aug 21, 2016 at 20:42

1 Answer 1

2

How about something like

var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
];

...

return dt.getDate() + "/" + monthNames[dt.getMonth()] + "/" + dt.getFullYear();

Other ideas can be found here: https://stackoverflow.com/a/1643468/5894196

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.