Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle timezones in CFML?

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.

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?

Or do you guys use any java methods?

like image 327
Henry Avatar asked Apr 27 '09 22:04

Henry


People also ask

How does SQL store time zones in database?

SQL Server: Use the DATETIMEOFFSET data type, which can store the timezone of UTC. MySQL: Use the TIMESTAMP data type which can include a timezone component. PostgreSQL: Use the TIMESTAMP WITH TIME ZONE data type as this can store the timezone of UTC.


1 Answers

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

Don't forget to check out his TZCFC test bed

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.

EDIT:

like image 77
Vincent Buck Avatar answered Sep 20 '22 11:09

Vincent Buck