按时间限制 ZrssFeed 显示的 RSS Feed
我正在使用 ZrssFeed 来显示 rss feed。我想将其限制为仅显示过去 8 小时内的帖子。
我尝试在 ZRSS 返回提要后添加以下代码块:
// Add feeds
for (var i=0; i<feeds.entries.length; i++) {
// Get individual feed
var entry = feeds.entries[i];
feedcount = i;
// Format published date
var entryDate = new Date(entry.publishedDate);
var pubDate = entryDate.toLocaleDateString() + ' ' + entryDate.toLocaleTimeString();
var msPerDay = 8*60*60*1000; // 8 hours
var msPubDateTime = new Date(pubdate); // item date in ms
if (msNow.getTime() - entryDate.getTime() < msPerDay) //compare
{
// rest of plugin
这两者都不起作用,并且似乎完全破坏了插件。
I'm using ZrssFeed to display an rss feed. I would like to limit it to only posts from the last 8 hours.
I tried adding the following block of code after ZRSS returns the feed:
// Add feeds
for (var i=0; i<feeds.entries.length; i++) {
// Get individual feed
var entry = feeds.entries[i];
feedcount = i;
// Format published date
var entryDate = new Date(entry.publishedDate);
var pubDate = entryDate.toLocaleDateString() + ' ' + entryDate.toLocaleTimeString();
var msPerDay = 8*60*60*1000; // 8 hours
var msPubDateTime = new Date(pubdate); // item date in ms
if (msNow.getTime() - entryDate.getTime() < msPerDay) //compare
{
// rest of plugin
This both doesn't work and seems to break the plugin altogether.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想查看 jsDate 脚本。它非常适合处理所有与日期相关的 JS 问题。
http://www.datejs.com/
You may want to look at the jsDate script. It's great at handling all date-related JS issues.
http://www.datejs.com/