I am running MYSQL in UTC by default. I want all selects to be done in the user's local time, but all inserts and updates to be in UTC. How do I do this? I know of the CONVERT_TZ function, but I don't want to have to wrap every select if at all possible. Is there a way to set the users timezone ONCE after they log in? I am using CodeIgniter and non-persistent so I assume I have to set it every time I connect?

Any advice is appreciated.

有帮助吗?

解决方案

in Your index.php file in the root Folder use:

date_default_timezone_set('Asia/Kolkata');

And Set your time zone here. All codeigniter Requests pass through this file. So it will set Your time Zone

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top