"Call to undefined function" error when calling function from a class

3

I have a function to convert the date, but it is returning an error that I could not adjust:

Follow the code below:

<?php

class Prog{

    private $DtBase;

    public function setdata($DtBase){
        $this->data = $DtBase;
    }
    public function getdata(){
        return convertData($this->data);
    }
    public function convertData($data){
        $data = Datetime::createFromFormat('d/m/Y', $data);
    return $data->format('Y-m-d');
    }
}

?>

Error calling function convertData :

  

Call to undefined function convertData () in Prog.php on line 11

Any tips?

    
asked by anonymous 23.03.2016 / 18:26

1 answer

4

In getData() you need to specify who is the invoker (owner) of this function (method), as in the case of the same object, the $this

Change:

return convertData($this->data);

To:

return $this->convertData($this->data);
    
23.03.2016 / 18:29