Jump to content

Recommended Posts

I'm trying to parse multiple rss feeds and only show and save items from the last month, but i can't get it to work.
All works fine, exept the part when i can't limit the data to only show last month.

I've tried this:

    $pubdate = date("Y-m-d", strtotime($item->pubDate));          
    if (date($pubdate, strtotime(" -1 month")))

 

Link to comment
https://forums.phpfreaks.com/topic/311132-only-show-rss-items-from-last-month/
Share on other sites

Fortunately it looks like you know that you need strtotime(), although you went for date() as well. Unfortunately it looks like you threw them together into some mismash thinking it might work.

strtotime() takes a date string and converts it into a number. Numbers are nice for comparisons. date() takes a number and converts it into a date string. Strings aren't nice for comparison.

Since numbers will be better than strings, what you need is to get a number for the publication date and a number for what was a month ago, then to compare the two.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.