ColdFusion and Daylight Savings Time

ColdFusion has a large number of date functions but not one to see if a past or future date occurs when daylight savings is in effect. However it is possible to find this out using a little Java code.

<cfset jtzobj = createObject("java","java.util.TimeZone")>
   <cfset timezone = jtzobj.getTimeZone(jtzobj.getDefault().ID)>
   <cfif timezone.inDaylightTime(datetime)>
      <cfoutput>#Dateformat(datetime)#</cfoutput> is daylight savings time
   <cfelse>
      <cfoutput>#Dateformat(datetime)#</cfoutput> is standard time
   </cfif>

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Copyright © Justin Mclean 2008
BlogCFC by Raymond Camden.