I got this error when I requested to update the PHP version from 5.2.17 to PHP 5.3.21 on the server.
I am hosting my EC2 and S3 bucket in us-west-2 (Oregon) region. When I was calling $s3client->listBuckets()
to list existing buckets in my php, I was getting exception - "Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings...".
I made below changes to make it work. Sharing these details in case someone is facing similar issue and any of above answers have not helped.
ntpstat
command. If you get error, this link helps you to know what is going wrong.date.timezone
was not set to any value and also it was commented by default. I un-commented by removing ';' before this line and set its value to "UTC"
and saved the file.sudo service httpd restart
and sudo service ntpd restart
commands.After this I am able to list buckets successfully without any exception. Hope this helps.