-2

In javascript, how to bring the date from the format (dd-mm-yy) and display it on the page as (dd-mm-yyyy)? Ex: 10-Mar-15 to 10-Mar-2015

chat
  • 1
  • Use the standard [toLocaleDateString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString). – Shanoor Nov 26 '15 at 12:57

1 Answers1

1

This will give you the complete date - new Date(Date.parse("01-Jan-09"));

This will show date-month-year

var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];

var a = new Date(Date.parse("07-jul-89"));

alert(a.getDate()+"-"+monthNames[a.getMonth()]+"-"+a.getFullYear());

output - 7-july-1989

Node
  • 86
  • 5