Class \models\DateTime not found global functions

Put a backslash in from of the class name to indicate it is in the global namespace:

$time = new \DateTime(‘now’, new \DateTimeZone(‘UTC’));

Published by

Joel Bowers

Web developer since 1999. PHP, YII2, Laravel, Javascript, HTML, CSS, jQuery, Perl, Wordpress, MySQL.

Leave a Reply

Your email address will not be published. Required fields are marked *