Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

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

Between date function on all Pages

Go to End



Community Member, 3 Posts

10 November 2012 at 3:50am


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