0

我使用 Google Feed 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()
}

有人能帮忙吗?

4

1 回答 1

0

您可以使用您的publishedDate 字符串在 javascript 中创建日期并提取

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

getMonth() 你需要 +1 因为 getMonth 返回数组,所以它从 0 开始

于 2015-05-29T14:43:44.467 回答