在JavaScript中将日期格式化为MM / dd / yyyy

问题描述:

我有这样的日期格式'2010-10-11T00:00:00 + 05:30'。我必须使用JavaScript或jQuery格式化为 MM / dd / yyyy 。任何人都可以帮我这样做。

I have a dateformat like this '2010-10-11T00:00:00+05:30'. I have to format in to MM/dd/yyyy using JavaScript or jQuery . Anyone help me to do the same.

试试这个;请记住,JavaScript月份为0索引,而天数为1索引。

Try this; bear in mind that JavaScript months are 0-indexed, whilst days are 1-indexed.

var date = new Date('2010-10-11T00:00:00+05:30');
alert((date.getMonth() + 1) + '/' + date.getDate() + '/' +  date.getFullYear());