Find timezone offset for a specific date

ColdFusion , Java Add comments

ColdFusion's built in function getTimeZoneInfo() doesn't allow you to pass a date. It give you the server timezone info and offset as of "now" (as in, when the code is run). 

If you need to find the timezone offset for a specific date, you can use the TimeZone class from java. Here is the code.



<cfset myDate = "11/01/09" />
<cfset timeZone = createObject("java","java.util.TimeZone") />
<cfset myTimeZone = timeZone.getTimeZone("America/New_York") />
<cfset myTimeZoneOffset = myTimeZone.getOffset(1,year(myDate),month(myDate),day(myDate),dayOfWeek(myDate),0) />

 

1 response to “Find timezone offset for a specific date”

  1. ann Says:
    thanks

Leave a Reply





Powered by Mango Blog. Design and Icons by N.Design Studio