我正在尝试将rss提要的日期格式化为月/日/年(2012年8月3日)。我用下面的代码来实现这个目的:
// pubDate
postDate = new Date("Fri Aug 03 2012 06:08:11 GMT-0700");
// reformat pubDate
pubDate = postDate.getMonth() + "/" + postDate.getDate() + "/" + postDate.getFullYear();
// return pubDate
console.log(pubDate + " pubDate");在我当前的代码中,输出是7/3/2012,但是月份不正确。我得到7而不是8。我如何让它产生正确的月份?
演示:http://jsfiddle.net/LmZMX/
发布于 2012-08-03 21:38:09
getMonth()返回“一个数字,从0到11,代表月份”
(postDate.getMonth() + 1)https://stackoverflow.com/questions/11796843
复制相似问题