我在Infinityfree平台中托管了我的PHP网站,但是时区有一些错误

发布于 2025-02-10 20:25:25 字数 145 浏览 1 评论 0原文

我想从数据库中获取时间,并想向用户显示它,但是我看到插入的时区是绝对错误的,我知道该服务器中的时区不是“ Asia/kolkata”,但我可以更改它通过函数date_default_timezone_set()在PHP中可用,如果不是,则该怎么办?

I want to fetch the time from the database and want to show it to the user, but I saw the timezone inserted there, is absolutely wrong, I understood that the timezone is not 'Asia/Kolkata' in that server, but can I change it by function date_default_timezone_set() available in PHP, if not then how can I do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美人迟暮 2025-02-17 20:25:25

从PHP程序连接到数据库后,

SET time_zone = 'America/Halifax';

显然将SQL语句放在您自己的时区。服务器时区通常设置为UTC,但可以设置为所有者的本地时间。如果您没有设置自己的时区,则您将获得服务器的时区。

Right after you connect from your php program to the database, give the SQL statement

SET time_zone = 'America/Halifax';

Put in your own time zone, obviously. Server time zones are usually set to UTC, but may be set to the local time of their owners. If you don't set your own time zone, you'll get the server's time zone, whatever it happens to be.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文