I have a list of dates and need to enforce a limit, which is the list to not be older than today but more than 30 days ahead of today.
Is possible to modify what I have or do I need to use something like 'time' instead? if so how would I adjust what I have?
$date = new DateTime($page->meta_value);
if (strtotime($page->meta_value) > time()) {
echo '<h2><div class="date-title">';
echo $page->post_title.' - ';
echo '</div><div class="date-date">';
echo $date->format('d-m-Y').'<br/>';
echo '</div></h2>';
}
Thanks for reading :)
Try this:
Or up to this month only?
Things that can help you:
print date('Y-m-d',strtotime('last day of this month'));
http://php.net/manual/en/datetime.formats.relative.php
print date('Y-m-d',strtotime('+ 30 days'));
http://php.net/manual/en/datetime.formats.date.php
Read more here http://php.net/manual/en/datetime.formats.php