Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
400 views
in Technique[技术] by (71.8m points)

javascript - 在JavaScript中格式化日期为MM / dd / yyyy [重复](Format date to MM/dd/yyyy in JavaScript [duplicate])

This question already has an answer here:

(这个问题在这里已有答案:)

I have a dateformat like this '2010-10-11T00:00:00+05:30' .

(我的日期格式为'2010-10-11T00:00:00+05:30' 。)

I have to format in to MM/dd/yyyy using JavaScript or jQuery .

(我必须使用JavaScript或jQuery格式化为MM/dd/yyyy 。)

Anyone help me to do the same.

(任何人都帮我做同样的事情。)

  ask by Pradeep translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try this;

(试试这个;)

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

(请记住,JavaScript月份是0索引,而日期是1索引。)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...