TechnicallyChris.com

Technical and Personal Ramblings of a Bostonian
  • Home
  • About Chris
  • Donate
  • Contact Chris
Home > ColdFusion > Managing Your TimeZone with TimeZone.cfc

Managing Your TimeZone with TimeZone.cfc

September 3rd, 2006
Goto comments Leave a comment

Way back during my first professional, “on my own”, ColdFusion project, I was using ColdFusion 5.0. It was not too long after its release, and I found myself developing for users over multiple time zones. Not really something I had thought of before, I realized I was a bit stuck.

A day of reading newsgroups, best practices, and miscellaneous code snippets didn’t help much, but I did get to learn a ton about time zones. What I wound up doing was just building a profile for each of my users that included their time zone, and then using DateAdd to move the hours back and forth from what they were in my database. Daylight savings didn’t worry me much until I realized that DST varied not only in the US, but globally. Some locations didn’t use it at all, some locations offset was not in whole hour increments, and some cities in some places didn’t embrace it, while the rest of the country did. It grew into quite the large project. I’m sure there was a custom solution out there somewhere, but it wasn’t easy to find, and for what I needed time zones for, my solution worked.

Years later, the same application has gone through a few upgrades, and is now running on ColdFusion MX 7.x. The files I’ve used to manage time zones have upgraded over time, but are still a huge kluge.

Enter timeZone.cfc. This is not the horrific bundle of functions that I wrote for my original project, but instead a very well written CFC by Paul Hastings. Paul has done something, in my opinion, incredible with this one file. As the name implies, timeZone.cfc helps you manage time zones in your ColdFusion application. Instead of relying on databases or configuration files to manage time zone locations and offsets, Paul uses something only available with MX: Java. Letting Java remember all of that means that you no longer have to manage countries, time zones, DST, offsets, partial offsets, time zone names, etc. If something in the “real world” changes, just install the upgraded JVM on the server, and you know what everyone else knows.

The CFC came with a good set of instructions for the methods it exposes to you, all stored as a commented section within the CFC. Using this one CFC, you can now take any date and time, and without knowing anything about the source or destination time (except for the names), you can convert the time effortlessly. I urge anyone running ColdFusion MX and worried about globalization to seriously consider timeZone.cfc.

If you enjoyed this article or it helped you in any way, I’d appreciate it if you’d post a comment below to let me know. All code examples are for demonstration only and should be used at your own risk. I cannot accept liability for unexpected results.

Chris ColdFusion ColdFusion, TimeZones

Comments (0) Trackbacks (0) Leave a comment Trackback
  1. No comments yet.
  1. No trackbacks yet.
Subscribe to comments feed
Configuring Oracle for CFMX Standard Your New Development Database
RSS feed
  • Google
  • Youdao
  • Xian Guo
  • Zhua Xia
  • My Yahoo!
  • newsgator
  • Bloglines
  • iNezha

Sponsored By

Recent Posts

  • Just Bought the Google Nexus One
  • Seven Things I’ve Liked About Windows 7 in Seven Day
  • What’s Happened to Customer Service (Part 2)?
  • What’s Happened to Customer Service (Part 1)?
  • Capturing S.M.A.R.T. Hard Disk Data from WMI with AutoIt
  • Adjusting DCOM Settings via Script
  • How to Manually Call the Google Cache
  • RoboForm & RoboForm2Go Product Review
  • Updated PingCell Function for Excel
  • Creating Hyperlinks in Word and Excel Longer than 256 Characters

Categories

  • ColdFusion
  • Firefox
  • Google Nexus One
  • IIS
  • McAfee EE / SafeBoot
  • Microsoft Windows
  • Oracle
  • Random Code
  • Random Technology
  • Sports and Recreation
  • Subversion
  • The Untechnological

Archives

  • January 2010
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • October 2007
  • September 2007
  • August 2007
  • January 2007
  • November 2006
  • October 2006
  • September 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006

Meta

  • Register
  • Log in
PageRank
Top WordPress
Copyright © 2006-2010 TechnicallyChris.com
Theme by mg12. Valid XHTML 1.1 and CSS 3.