Welcome Guest, Not a member yet? Register   Sign In
Time::now() in every controller
#1

Hi there,

I know there will be a really simple answer to this that I am missing.

I want to use CI4's datetime class in pretty much every controller e.g.:

PHP Code:
echo Time::now() 
or
PHP Code:
$myTime = new Time('+3 week'); 

But I dont want to have to put:

PHP Code:
use CodeIgniter\I18n\Time

At the top of every controller.

Is there a way I can autoload the class?
I have already tried adding to the Autoload config in the $psr4 section and I have also tried adding the line to the top of the BaseController but nothing seems to work?

Am I missing something - could someone shed some light on this please.

Many thanks,
Ben
Reply


Messages In This Thread
Time::now() in every controller - by beng - 03-28-2020, 09:05 AM
RE: Time::now() in every controller - by maxxd - 03-29-2020, 07:28 AM
RE: Time::now() in every controller - by beng - 03-29-2020, 07:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB