Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cakephp3 Class DateTime not found

I'm trying to convert my cakephp plugin from 2.X to 3.

I have a little problem inside my component plugin at this line:

$dStart = new DateTime($now); //$now = date('Y-m-d H:i:s');

return me this error:

Error: Class 'CurrencyConverter\Controller\Component\DateTime' not found 

Seems that it search DateTime inside my plugin directory. How can I solve it?

Thanks

like image 486
Alessandro Minoccheri Avatar asked Apr 07 '15 19:04

Alessandro Minoccheri


1 Answers

Try:

$dStart = new \DateTime($now);

because CakePHP 3.0 using namespaces and if you not add a root namespace it will be looking for class under current namespace.

like image 199
marian0 Avatar answered Oct 08 '22 00:10

marian0