如何处理 CFML 中的时区? [英] How to handle timezones in CFML?

查看:16
本文介绍了如何处理 CFML 中的时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 CFML 中处理时区?到目前为止,我编写的所有应用程序都只使用 CF 服务器和/或 SQL 服务器的默认时区.

How to handle timezones in CFML? So far all apps I've wrote just use the default timezone of the CF server and/or SQL server.

你们平时都做什么?您是否使用 GetTimezineInfo() 然后 DateAdd() 将所有日期存储在 GMT 中,并根据登录用户的偏好将所有时间转换为正确的时区?

What do you guys usually do? Do you store all dates in GMT with GetTimezineInfo() and then DateAdd(), and translate all time to the correct timezone based on logged in user's preference?

或者你们使用任何java方法吗?

Or do you guys use any java methods?

推荐答案

前段时间我正在研究这个问题,发现 Paul Hasting 的博客 和 Coldfusion/Java 示例非常有用:

I was looking into the issue some time ago and found Paul Hasting's blog and Coldfusion/Java examples very helpful:

别忘了看看他的 TZCFC 测试台

如何存储日期可能取决于您的业务逻辑.在我做过的一个项目中,我们必须跨时区实施人力资源调度,我们将日期/时间存储在 UTC 中,并在数据库中使用 datediff 来检查冲突.

How to store dates will probably depend on your business logic. In a project I did where we had to implement human resource scheduling across timezones we stored dates/times in UTC and used datediff in the database to check for conflicts.

这篇关于如何处理 CFML 中的时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆