function set($value) { // value can be passed as YYYY-MM or as full date (YYYY-MM-DD) if (strtotime($value) === false) { $value .= '-01'; } $tm = strtotime($value); $yr = date('Y', $tm); if ($yr > $this->year_to) { $yr = $this->year_to; } elseif ($yr < $this->year_from) { $yr = $this->year_from; } $this->c_year = $yr; $this->c_month = date('m', $tm); return parent::set($value); }
function set($value) { /*if(is_null($value)){ return; }*/ if (is_null($value) || $value == '' || $value == '0000-00-00' || false === ($tm = strtotime($value))) { $this->disable(); } else { $yr = date('Y', $tm); if ($yr > $this->year_to) { $yr = $this->year_to; } elseif ($yr < $this->year_from) { $yr = $this->year_from; } $this->c_year = $yr; $this->c_month = date('m', $tm); $this->c_day = date('d', $tm); $this->enable(); } return parent::set($value); }