Search code examples
phpmysqlfilterkohanadate-conversion

Date conversion to database date


I am using Kohana 3.1

Model:

    public function filters()
    {
        $filters = parent::filters();

        $filters['birthday'] = array(
            array('date', array('Y-m-d', strtotime(':value')))
        );

        return $filters;
    }

birthday input(form value):

23/05/1989

database output:

1969-12-31

What am I doing wrong?


Solution

  • public function filters()
    {
        $filters = parent::filters();
    
        $filters['birthday'] = array(
            array(function($value) {
                return date('Y-m-d', strtotime($value));                
            })
        ); 
    
        return $filters;
    }
    

    Anonymous Methods is the answer!

    Thank you all for your inputs.