本文介绍了cakephp3类DateTime找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将我的cakephp插件从2.X转换为3。
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');
返回此错误:
Error: Class 'CurrencyConverter\Controller\Component\DateTime' not found
$ b b
似乎它在我的插件目录中搜索DateTime。
我如何解决它?
Seems that it search DateTime inside my plugin directory.How can I solve it?
感谢
推荐答案
尝试:
$dStart = new \DateTime($now);
因为CakePHP 3.0使用命名空间,如果不添加根命名空间,命名空间。
because CakePHP 3.0 using namespaces and if you not add a root namespace it will be looking for class under current namespace.
这篇关于cakephp3类DateTime找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!