Hi,
Before in CodeIgniter 3 I used to change the MySQL timezone with a query inside MY_Controller.
Now in CodeIgniter 4 I'm doing the same in the BaseController:
PHP Code:
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
// Do Not Edit This Line
parent::initController($request, $response, $logger);
date_default_timezone_set('Europe/Amsterdam');
$utc_offset = date('P');
$db = \Config\Database::connect();
$db->query('SET time_zone = "'. $utc_offset .'"');
}
I double checked, and it's running the query okay.
However when I retrieve data from the database, the datetimes are still on mysql server timezone UTC.
Ofcourse I can converse every datetime I retrieve from the database in my PHP code, however I prefer not to do this, as it will require me to do this on many points.
Thank you,
Roel.
I solved the issue, it seems if I use time or datetime in the data column type it does notchange it by timezone, only when using the timestamp column type.