What is the solution to the error below?
public function __toString(){
return json_encode(array(
"idusuario" =>$this->getIdusuario(),
"deslogin" =>$this->getDeslogin(),
"dessenha" =>$this->getDessenha(),
"tdcadastro" =>$this->getDtcadastro()->format("d/m/Y - H: i: s")
));
}
This is the error:
Fatal error: Method User :: __ toString () must not throw an exception, caught Error: Call to a member function format () on null in