交响乐 +时区:用户和服务器时区之间(自动)转换?
我有一个现有的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可以,但您可以向过滤器链添加一个过滤器,该过滤器在发送任何其他查询之前对打开的数据库连接执行
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.