简体   繁体   English

从 phpMyAdmin 更改 mysql 时区

[英]Change mysql timezone from phpMyAdmin

I am trying to change the timezone of my database.我正在尝试更改数据库的时区。 I am on shared server and database support guys can not change it for me only.我在共享服务器上,数据库支持人员不能只为我改变它。 Time zone is currently +1:00 I want it as +05:30 .时区目前是+1:00我希望它是+05:30 I searched and tried following but nothing worked.我搜索并尝试跟踪但没有任何效果。

date_default_timezone_set('timezone_name');

Added to my index.php file.添加到我的index.php文件中。

mysql> SET GLOBAL time_zone = 'timezone_name';

It says access restricted.它说访问受限。

SET time_zone = timezone_name

Query run now row affected.查询运行现在行受影响。

My site is hosted on site-ground us server.我的网站托管在网站地面美国服务器上。

As I am on shared server my provider did not change it only for me.由于我在共享服务器上,我的提供商并没有仅为我更改它。 So after search I fount that, I have to use datetime type on sql instead of current time stamp and as madipradhana said I was updated my php.ini or .htaccess .所以在搜索之后我发现,我必须在 sql 上使用datetime类型而不是当前时间戳,正如 madipradhana 所说,我更新了我的php.ini.htaccess

Probably you can change the timezone in .htacess without touching your PHP scripts or MySQL query.也许您可以在 .htacess 中更改时区,而无需触及您的 PHP 脚本或 MySQL 查询。 Open up your .htaccess file, enter the command as below.打开您的.htaccess文件,输入如下命令。

SetEnv TZ your_timezone

For example, enter this command if your location in Jakarta例如,如果您的位置在雅加达,请输入此命令

SetEnv ID Asia/Jakarta

Refer to the link below for available timezone:有关可用时区,请参阅以下链接:

http://php.net/manual/en/timezones.php http://php.net/manual/en/timezones.php

As you are on shared server use date() of php and set date_default_timezone_set('timezone_name');当您在共享服务器上时,请使用 php 的date()并设置date_default_timezone_set('timezone_name'); to your index.php到你的index.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM