0

I have implemented a system in my internal server

When insert record there is a current date field which is the timestamp and by default is the current time.

It works fine on local server until recently I need to move the database to Amazon RDS, it is set UTC instead of UTC + 8.

So , instead of changing every query in my models PHP , are there any more convenient way to adapt the changes?

I am using codeigniter and after some searching , it suggest using procedure like this:

Amazon RDS - are there workarounds to change a database time zone in SQL Server?

DELIMITER |
CREATE PROCEDURE mysql.init_connect_procedure () 
IF  NOT(POSITION(‘rdsadmin@’ IN user()) = 1) 
THEN SET SESSION time_zone = 'America/New_York';
END IF |
DELIMITER ;

The problem is it that need to be call everytime I run the query? so that how to modify the codeigniter Model class to run that?

Thanks a lot.

Community
  • 1
  • 1
user3538235
  • 1,991
  • 6
  • 27
  • 55

1 Answers1

0

I work with codeigniter and I find that using the php date_default_timezone_set('') solved the problem for me. Hope this helps.

sunil
  • 177
  • 1
  • 7
  • so for the create date do I need to insert using date() ? I perfer not to edit like this as there are a lot of queries thanks – user3538235 Sep 11 '15 at 03:14
  • If i understand correctly, your actual requirement is independent of codeigniter. If it is, then does the link in the comment above by Keval answer your question? – sunil Sep 11 '15 at 09:52