PHP DateTime class Namespace
DateTime
is in the global namespace, and as "class names always resolve to the current namespace name" you have to use \DateTime
.
Or import the package using:
use \Datetime;
Better solution for using classes in global namespaces is "use" keyword instead of "\" before class.
namespace SDCU\GeneralBundle\Entity;
use \DateTime;
class Country
{
public function __construct(){
$this->insertedAt = new DateTime();
}
}