交响乐 +时区:用户和服务器时区之间(自动)转换?

发布于 2024-11-26 02:57:13 字数 189 浏览 6 评论 0原文

我有一个现有的 Symfony 1.2/Propel 项目,该项目已被修改为可以在各种其他语言/时区中运行。当前的硬件设置和大多数语言将在 CET 中运行,但某些语言将在不同时区运行。

我是否有机会轻松地将用户日期时间输入从 BST 转换为 CET,反之亦然,而无需触及对 DateTime-functions/FormWidgets 的所有调用?

I have an existing Symfony 1.2/Propel project which has been modified to run in various other languages/timezones. The current hardware setup and most of the languages will run in CET, but some languages will operate in different timezones.

Is there any chance I can easily convert user datetime inputs from, let's say BST to CET and vice-versa, without touching all calls to DateTime-functions/FormWidgets?

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

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

发布评论

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

评论(1

完美的未来在梦里 2024-12-03 02:57:13

不可以,但您可以向过滤器链添加一个过滤器,该过滤器在发送任何其他查询之前对打开的数据库连接执行 SET TIME_ZONE = ? 查询...将其设置为用户的时区。

除此之外,良好的时区支持需要一些编码。我通常最终会在模型类中实现从 GMT(我存储所有日期时间)到用户本地时区的所有转换,反之亦然。

No, but you could add a filter to the filter chain that executes a SET TIME_ZONE = ? query on the open database connection before any other queries are sent... to set it to the user's time zone.

Beyond that, good time zone support requires some coding. I usually end up implementing all the conversions from GMT (which I store all datetimes in) to the user's local time zone or vice versa in the model classes.

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