cakephp3 Class DateTime not found

醉酒当歌 提交于 2019-12-10 02:22:41

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/29500225/cakephp3-class-datetime-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!