在javascript中自定义日期以匹配格式

在javascript中自定义日期以匹配格式,javascript,feed,Javascript,Feed,我试图从我的RSS订阅源中定制日期,以显示它在google订阅源主页“2011年5月12日”上的显示方式。我试着在谷歌操场上修改代码(http://code.google.com/apis/ajax/playground/#historical_entries)但对我来说,它显示为2011年5月24日星期二13:02:48 GMT-0700(太平洋夏令时)。我四处搜索,发现我必须使用google.feeds.ShortDatePattern,但无法确定在哪里以及如何使用。这是我目前的代码: /*

我试图从我的RSS订阅源中定制日期,以显示它在google订阅源主页“2011年5月12日”上的显示方式。我试着在谷歌操场上修改代码(http://code.google.com/apis/ajax/playground/#historical_entries)但对我来说,它显示为2011年5月24日星期二13:02:48 GMT-0700(太平洋夏令时)。我四处搜索,发现我必须使用google.feeds.ShortDatePattern,但无法确定在哪里以及如何使用。这是我目前的代码:

/*
*  How to see historical entries in a feed.  Usually a feed only returns x number
*  of results, and you want more.  Since the Google Feeds API caches feeds, you can
*  dig into the history of entries that it has cached.  This, paired with setNumEntries,
*  allows you to get more entries than normally possible.
*/

google.load("feeds", "1");

// Our callback function, for when a feed is loaded.
function feedLoaded(result) {
  if (!result.error) {
    // Grab the container we will put the results into
    var container = document.getElementById("content");
    container.innerHTML = '';

    // Loop through the feeds, putting the titles onto the page.
    // Check out the result object for a list of properties returned in each entry.
    // http://code.google.com/apis/ajaxfeeds/documentation/reference.html#JSON
    for (var i = 0; i < result.feed.entries.length; i++) {
      var entry = result.feed.entries[i];
      var date = new Date(entry.publishedDate);
      var div = document.createElement("div");
      var link = document.createElement("a");   
      link.setAttribute('href', entry.link);   
      link.appendChild( document.createTextNode( date + " " + entry.title));
      div.appendChild(link);
      container.appendChild(div);
      var content = document.createElement("div");
      content.appendChild(document.createTextNode(entry.contentSnippet));
      container.appendChild(content);
    }
  }
}

function OnLoad() {
  // Create a feed instance that will grab Digg's feed.
  var feed = new google.feeds.Feed("http://www.digg.com/rss/index.xml");

  feed.includeHistoricalEntries(); // tell the API we want to have old entries too
  feed.setNumEntries(5); // we want a maximum of 250 entries, if they exist

  // Calling load sends the request off.  It requires a callback function.
  feed.load(feedLoaded);
}

google.setOnLoadCallback(OnLoad);
/*
*如何查看提要中的历史条目。通常,提要只返回x个数字
*你想要更多的结果。由于GoogleFeedsAPI缓存提要,您可以
*深入研究它缓存的条目的历史记录。这一款,配上setNumEntries,
*允许您获得比正常情况更多的条目。
*/
加载(“提要”,“1”);
//我们的回调函数,用于加载提要时。
功能加载(结果){
如果(!result.error){
//抓起我们将结果放入的容器
var container=document.getElementById(“内容”);
container.innerHTML='';
//循环浏览提要,将标题放在页面上。
//检查结果对象以获得每个条目中返回的属性列表。
// http://code.google.com/apis/ajaxfeeds/documentation/reference.html#JSON
对于(变量i=0;i
您可以尝试类似于纯javascript的方式