-5

I have tried the following, but the output is not as expected.

title = "Jun 25 2014";
var n = new Date(title);
var dateformat = n.toLocaleDateString();
wojciii
  • 4,253
  • 1
  • 30
  • 39

1 Answers1

1

Use below code to get your output

var title = "Jun 25 2014";
var n = new Date(title);

if(n.getMonth()+1 < 10)
    var month = '0'+(n.getMonth()+1);
var date = month+'/'+n.getDate()+'/'+n.getFullYear();
alert(date);
Sid
  • 801
  • 8
  • 19