AWS time zone adjust Amazon Linux 2 and RDS MySQL PHP


In the logs and the database use the correct time stamp of the own time zone, must be

1. Configure the system time of the EC2 instance

sudo ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime

and in the file /etc/sysconfig/clock Enter the time zone:

sudo vi /etc/sysconfig/clock
ZONE="Europe/Berlin"

After a reboot of the instance must be:

sudo reboot

The adjustment can be checked with

date

Those

2. Customize the MySQL RDS ParameterGroup

Setting the parameter time_zone on the value Europe/Prague, After a reboot of the RDS instance is necessary

aws_rds_time_zone

Parameter set time_zone MySQL RDS ParameterGroup

The adjustment can be checked with

SELECT NOW();

Those

3. PHP

Finally, in the php.ini, the time zone has to be changed:

sudo vi /etc/php.ini

date.timezone = "Europe/Berlin"

Test by means of:

php -r 'echo date("c");'

 

Comments are closed.