2015-05-29 63 views
0

删除时间,我需要从公布日期删除“出版时间”和只显示“日期”。如何从我创建了使用谷歌API饲料RSS源饲料发布日期

我有这段代码。

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++) 
      rssoutput += "<li><a href='" + thefeeds[i].link + "'>" + thefeeds[i].publishedDate + "</a></li>" 
     rssoutput += "</ul>" 

     feedcontainer.innerHTML = rssoutput 
    } 
    else 
     alert("Error fetching feeds!") 
} 

window.onload = function() { 
    rssfeedsetup() 
} 

任何人都可以帮忙吗?

回答

0

你可以在JavaScript中创建一个日期与您publishedDate串并提取个月天。

var dt = new Date(thefeeds[i].publishedDate); 
dt.getFullYear() + '/' + (dt.getMonth() + 1) + '/' + dt.getDate(); 

得到月(),你需要+1的Cuz的getMonth返回的数组,所以其在0

启动