Coldfusion Time Zone Fun!
I’ve been dealing with a lot of weird time-scheduling fun with coldfusion. Essentially I was building a feature that allowed users to pick an hour and minute to get a daily reminder of either today’s appointments or tomorrow’s. This was shortly after our application switched our database to postgresql, and I got excited about the cool data types available in postgres. Unfortunately, CF’s ORM doesn’t play nice with those, so I couldn’t use them. Anywho, after doing some pretty gross stuff data-wise to handle this feature, reports came in of reminders not coming in on time. I tracked it down to where I was checking to see if we’ve already sent this reminder out in the past 24h or not. I had stored that time in the database as UTC. Now, I had already converted the server time for now() to utc using dateConvert('local2utc', now()); I then used datediff() to determine the number of hours between now and the time the reminder was last processed. When the times looked like they were 24 hours apart, datediff returned 20 hours and was causing some trouble. It turns out, because I had done that conversion, CF was nice enough to remember the original time it came from and used that in the datediff calculation. I had assumed Dates in CF were not TZ-aware. I was wrong! Anyway, to make CF forget about the TZ that the servertime came from, a simple toString() around the date worked.
Lesson learned: CF Dates can be TZ-aware.
















