0

I want to get all the channel entries for next next six months starting at the next month. I can use the month_limit and set it to 6 and I can use the start_on parameter to specify what date to start on but how do I get the 1st of the next month into that parameter? So today being April 1st I want the start_on parameter to have 5/1/2015 00:00, how to do I get that into the start_on parameter?

1

I would use an addon like this:

http://www.solspace.com/docs/date_field_filter/usage/

and you could throw on PHP parsing on that template and set a future date var:

<?php
$enddate = new DateTime();
$enddate->modify("+6 month");
?>

and your channel:entries tag would look something like this:

{exp:channel:entries
    date_field="entry_date"
    date_field_start="{current_time format='%m/%d/%Y %h:%i'}"
    date_field_stop="<?php echo $enddate->format("m/d/Y h:i"); ?>"
}

You can mess with PHP DateTime to get the 0 hour of the current date I believe, do some reading at the docs:

http://php.net/manual/en/class.datetime.php

2
  • The end date was not what I was after but I used your example for the start date: $startdate->modify("+1 month"). I really hate putting php in my templates but that works so I will go with it for now.
    – Trevor Orr
    Apr 1 '15 at 16:46
  • If you're addon savvy, you could write a plugin in about a minute that just dumps out whatever future DateTime you need from the current DateTime. Depends on how wide spread your need for this is, but that would get PHP out of your templates.
    – jrothafer
    Apr 1 '15 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.