我正在尝试从 RSS Feed 中解析 publishedDate,但没有成功...
我可以使用此代码显示日期:thefeeds[i].publishedDate
.. 结果是:Sat, 02 Feb 2013 22:00:00 -0800
但是,我希望这更友好...
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
var feedcontainer=document.getElementById("feeddiv")
var feedurl="http://feeds.folha.uol.com.br/folha/classificados/empregos/rss091.xml"
var feedlimit=4
var rssoutput="<ul>"
function rssfeedsetup(){
var feedpointer=new google.feeds.Feed(feedurl) //Google Feed API method
feedpointer.setNumEntries(feedlimit) //Google Feed API method
feedpointer.load(displayfeed) //Google Feed API method
}
function displayfeed(result){
if (!result.error){
var thefeeds=result.feed.entries
for (var i=0; i<thefeeds.length; i++){
<!-- I THINK I'M DOING THIS LINES WRONG!! -->
var pubDate = thefeeds[i].publishedDate
var date = new Date(pubDate);
var months = Array("Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro");
var string = date.getDate() + " " + months[date.getMonth()] + " " + date.getFullYear()
<!-- END -->
rssoutput+="<li><span>•</span> " + string + " - <a href='" + thefeeds[i].link + "' target='_blank'>" + thefeeds[i].title + "</a></li>"
rssoutput+="</ul>"
feedcontainer.innerHTML=rssoutput
}
else
alert("Erro ao carregar as notícias!")
}
window.onload=function(){
rssfeedsetup()
}
</script>
怎么了?