> must.. * freq_hourly = 'what hours' << OR IF EMPTY USES TIME FROM DTSTART * /* the code above is auto generated do not remove the tag below */ function notifytimesRange($advance) { $start = date('Y-m-d H:i:s', max(strtotime("NOW - 24 HOURS"), strtotime($this->dtstart))); $end = date('Y-m-d H:i:s', min(strtotime("NOW + $advance DAYS"), strtotime($this->dtend))); } function notifytimes($advance) { // make a list of datetimes when notifies need to be generated for. // it starts 24 hours ago.. or when dtstart list($start, $end) = $this->notifytimesRange($advance); if (strtotime($start) > strtotime($end)) { return array(); // no data.. } $ret = array(); $hours = array_unique(json_decode($this->freq_hour)); $days = json_decode($this->freq_day); foreach($days as $d){ foreach($hours as $h){ $ret[] = date('Y-m-d', strtotime($d)) . ' ' . $h; } } return $this->applyTimezoneToList($ret); } function applyTimezoneToList($ar) { $ret = array(); foreach($ar as $a) { $date = new DateTime($a); $date->setTimezone(new DateTimeZone($this->tz)); $ret[] = $date->format('Y-m-d H:i'); } return $ret; } function generateNotifications(){ //DB_DataObject::debugLevel(1); $w = DB_DataObject::factory($this->tableName()); $w->find(); while($w->fetch()){ $notifytime = $w->notifyTimes(2); var_dump($notifytime); } } }