php - 更改共享服务器上的 PHPmyadmin 时区

标签 php mysql phpmyadmin

我尝试使用 CURRENT_TIMESTAMP 保存数据库中的查询时间。问题是时区不正确,当我与 HostGator 支持人员交谈时,他们给了我这个答案:

Thomas after researching this issue, I found that you can only change it on the site, to change it on phpmyadmin you would need root access which you do not posses on a shared server.

服务器与我的祖国(智利)有2个小时的时差。有人知道我能做什么吗?我使用此代码来更新数据库:

<?php

$lat = $_GET['lat'];
$lon = $_GET['lon'];

// Make a MySQL Connection

$db_database = "xxx";
$db_hostname = "xxx";
$db_username = "xxx";
$db_password = "xxx";


$enlace = mysql_connect($db_hostname, $db_username, $db_password);
if (!$enlace) {
    die('No pudo conectarse: ' . mysql_error());
}
echo 'Conectado satisfactoriamente. <br>';
// mysql_close($enlace);


mysql_select_db('xxxxx') or die(mysql_error());


$q = "INSERT INTO `posicion` (`Hora`, `Latitud`, `Longitud`) VALUES 
 (NULL, '$lat','$lon')";

//Run Query
$result = mysql_query($q) or die(mysql_error());

echo "Tamos redi";

?>

“Hora”列的配置为:

enter image description here

有没有人想办法解决这个问题?

谢谢!

最佳答案

如果是共享主机,您需要联系支持人员或进行实时聊天,他们可以为您更改默认时区。

您可以使用date_default_timezone_set()来设置默认时区。

请看一下here

在服务器端将所有时间转换为 UTC,然后直接使用 UTC

关于php - 更改共享服务器上的 PHPmyadmin 时区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26430484/

相关文章:

php - 在 phpmyadmin 中创建触发器

php - 检查 MySQL 行中是否存在值

php - 使用 MySQL 计算唯一 IP 地址

php - 将 YouTube URL 替换为 MySQL PHPMyAdmin 中的嵌入代码

mysql - "UNSIGNED": syntax error: on creating table query when imported to sqlite

php - 执行代码后显示空白页

php - Google 通知 channel 允许的最长过期时间是多少?

php - 无法正确执行mysql查询

mysql - 如何更改mysql用户权限?

php - 如何通过仅单击 html 中的提交按钮自动单击超链接(<a> 标记)?