I’m running nginx php and mysql in the same droplet but php and mysql gives different times. Mysql is approximately 8 hours before the php time. Actually, I need only to have the UTC times both in php and mysql. What should I do?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
After reconfiguration of system timezone you might need to restart mysql to make the changes take effect
sudo /etc/init.d/mysql restart
What OS are you using? You can check the system timezone on Ubuntu or Debian with: <br> <br><pre> <br>cat /etc/timezone <br></pre> <br> <br>and you can set it to something else using: <br> <br><pre> <br>sudo dpkg-reconfigure tzdata <br></pre> <br> <br>You can check the mysql timezone with: <br> <br><pre> <br>SELECT @@global.time_zone, @@session.time_zone; <br></pre> <br> <br>You can check the php timezone with: <br> <br><pre> <br>$tz = date_default_timezone_get(); <br>echo $tz; <br></pre> <br> <br>Both php and mysql should have defaulted to system time, but if they aren’t respecting that for some reason you can change them. <br> <br>In mysql: <br> <br><pre> <br>SET GLOBAL time_zone = timezone; <br></pre> <br> <br>In php: <br> <br><pre> <br>date_default_timezone_set(‘timezone’); <br></pre> <br> <br>See also: <br> <br>https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html <br>http://php.net/manual/en/function.date-default-timezone-set.php
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.