Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Between date function on all Pages

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 315 Views
  • JanJan
    Community Member
    3 Posts

    Between date function on all Pages Link to this post


    I have this function which works on the productpagina page itself, but not on other pages. Basicly what it does and needs to do on other pages is to display a product when it is between 2 dates that are filled in. Im not much a php expert, so i was hoping someone here might be able to help me with this.

    The thing i dont get working on the other pages is the start and end date.. im not sure how to define them in the page.php.. since $this-Begin,time() doesnt work. I've tried a couple of things, but they dont seem to work.

    function BetweenDates() {

    $begin = date($this->Begin,time()); //Begin date
    $einde = date($this->Einde,time()); // End Date

    $today = date('Y-m-d', time());

    $Productpaginas = DataObject::get('Productpagina', '','','',null);   //Get the class

    foreach($Productpaginas as $Productpagina){
    if ($begin <= $today && $einde >= $today ){
              return $Productpagina;
              } else{
              return false;
    return $Productpaginas;


    Kind Regards, Jan

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.