- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 gmdate PHP 函数将当前日期插入数据库,但它显示的是 GMT 时间,我可以将其更改为我的时区 +3 吗?
这是代码
$sql = "INSERT INTO Students
VALUES ('','" . $info[$i]['firstname'] . "', '" . $info[$i]['lastname'] . "',
'" . $info[$i]['sex'] . "', '" . $info[$i]['major'] . "',
'" . $info[$i]['favorite'] . "', '" . $info[$i]['GPA'] . "',
'". gmdate('m/d/Y g:i:s A') . "')" ;
最佳答案
“+3”不是“时区”。这是与 UTC/GMT 的偏移量,可能会根据 DST 设置在全年发生变化。 时区类似于“欧洲/柏林”或“亚洲/东京”。
一旦你决定了一个真正的时区:
date_default_timezone_set('Europe/Berlin');
echo date('m/d/Y g:i:s A');
或
$date = new DateTime('now', new DateTimeZone('Europe/Berlin'));
echo $date->format('m/d/Y g:i:s A');
如果您只需要使用“+3”,那么 a)您就完蛋了,b)您可以简单地将“3 小时”添加到任何时间戳:
date_default_timezone_set('UTC');
echo date('m/d/Y g:i:s A', strtotime("$offset hours"));
echo date('m/d/Y g:i:s A', time() + ($offset * 60 * 60));
$date = new DateTime;
$date->modify("$offset hours");
echo $date->format('m/d/Y g:i:s A');
关于php - 更改 gmdate PHP 函数的时区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17005131/
这个问题不太可能帮助任何 future 的访客;它只与一个小地理区域、一个特定时刻或一个非常狭窄的情况相关,而这些情况通常不适用于互联网的全局受众。如需帮助使这个问题更广泛地适用,visit the
我想从 PHP 脚本中的 GMDATE()(用于 UTC 目的)中减去 180 天。我刚刚看过 SO,但几乎没有人在使用 gmdate()。 这是我的: $from_date = gmdate("Y-
我想从 PHP 脚本中的 GMDATE()(用于 UTC 目的)中减去 180 天。我刚刚看过 SO,但几乎没有人在使用 gmdate()。 这是我的: $from_date = gmdate("Y-
我正在尝试签署 Amazon 请求,并且需要以下时间戳格式: gmdate('Y-m-d\TH:i:s\Z'); 如何在nodejs环境中获取它?非常感谢。 最佳答案 对于任何需要这个的人: new
我正在尝试以这种方式更新一些大表: 每个表都有大约 80.000 行,处理将花费太多时间才能完成。我如何使用 mysql 中 gmdate 的等效函数来解决这个问题?谢谢! :) 最佳答案 可以使用
我正在使用 gmdate PHP 函数将当前日期插入数据库,但它显示的是 GMT 时间,我可以将其更改为我的时区 +3 吗? 这是代码 $sql = "INSERT INTO Students VAL
我发现了一些我无法真正解释的东西,也许这里有人可以给我一个提示。 我有以下测试代码,它使用 date() 和 gmdate():
我有一种情况,我在两个不同的 codeigniter Controller 中使用 php 函数 gmdate()。 Controller 使用完全相同的调用返回 6 小时的差异。 下方是返回正确 G
我是一名优秀的程序员,十分优秀!