I'm scraping a page for articles which all contains of a date in the following format:
2012-08-20T11:04:00+0200
What I want to do is to stop retrieve articles if the next article is posted 12 months from todays date. The way I can think of is the following:
while ($retrieveArticles == true) {
$stopDate = date('Y-m-d'); // <--- this gives me todays date while I need the date 12 months ago.
$date = $article->find('header div p span', 1);
$date = substr($date->title, 0, 10); // <--- becomes 2012-08-20
if ($date >= $stopDate) {
$retrieveArticles = false;
}
... not relevant code
}
What I need help with:
How can I subtract 12 months from todays date?
Am I thinking right by doing like this or is there better and more elegant ways of achieve what I want?
Thanks in advance!