Reputation: 8726
I'm trying to create a public/private function inside my controller (say PostController) to tidy up certain code.
I wrote something like this:
class PostController extends BaseController
{
public function store()
{
$startdate = dateformatchange(Input::get('startdate'));
}
public function dateformatchange($date)
{
$dateString = DateTime::createFromFormat('m-d-Y', $date);
$dateNew = $dateString->format('Y/m/d');
return $dateNew;
}
}
But I'm getting some error. Call to undefined function dateformatchange()
Am I doing it wrong? please advice where I went wrong. Sorry if it is a silly mistake.
Upvotes: 2
Views: 462
Reputation: 60048
You need to do it like this:
$startdate = $this->dateformatchange(Input::get('startdate'));
Upvotes: 4