Guldstrand Posted July 19, 2020 Share Posted July 19, 2020 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"))) Quote Link to comment https://forums.phpfreaks.com/topic/311132-only-show-rss-items-from-last-month/ Share on other sites More sharing options...
requinix Posted July 19, 2020 Share Posted July 19, 2020 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. Quote Link to comment https://forums.phpfreaks.com/topic/311132-only-show-rss-items-from-last-month/#findComment-1579822 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.