pencial
pencial

Reputation: 71

getting error with zend 2 and DateTime object

I'm trying get current date in zend 2 , I use this code to get current date and time

$datetime = new DateTime();

But it throw an error "Class 'Application\Controller\DateTime' not found in C:\wamp\www\zf2\module\Application\src\Application\Controller\IndexController.php on line 26

how can I fix this bug? thank you so much :)

Upvotes: 0

Views: 858

Answers (1)

Finbarr
Finbarr

Reputation: 486

$datetime = new \DateTime("now");

or if you dont like the backslash include

use DateTime;

at the start of your file and then the format is;

$datetime = new DateTime("now");

Upvotes: 3

Related Questions