I am facing a very weried problem
I am trying to using new php "DateTime" class for date. I am using latest php 5.3.12.
The code works fine when i use normal php code. (I means other non Zend application), but when i used the same code in a controller., it gives me error
Fatal error: Class 'User\Controller\DateTime' not found in C:\wamp\www\1625\module\User\src\User\Controller\UserController.php on line 65
I didn't get because "DateTime" is php inbuild class
The code is below
$date = new DateTime(date('Y').'-'.date('m').'-01');
echo "<li>".$date_now = $date->format('Y-m-d');
Since you are inside a namespace, you should call the base DateTime
class as
$date = new \DateTime(date('Y').'-'.date('m').'-01');
which, for clarity, you could rewrite as
$date = new \DateTime(date('Y-m-01'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With