Skip to content

Instantly share code, notes, and snippets.

@recantha
Created July 12, 2024 09:00
Show Gist options
  • Save recantha/bd54dbc575e5377346268170d8fe28c4 to your computer and use it in GitHub Desktop.
Save recantha/bd54dbc575e5377346268170d8fe28c4 to your computer and use it in GitHub Desktop.
A CFML function to determine whether a date is in GMT or BST for the Europe/London region
<cffunction name="getDateTimeZone" returntype="string" access="public">
<cfargument name="the_date" type="date" required="true">
<cfset var local = {}>
<cftry>
<cfset local.timezone = "">
<cfset local.obj_timezone = createObject("java", "java.util.TimeZone").getTimeZone("Europe/London")>
<cfset local.is_daylight_time = local.obj_timezone.inDaylightTime(arguments.the_date)>
<cfif local.is_daylight_time>
<cfset local.timezone = "BST">
<cfelse>
<cfset local.timezone = "GMT">
</cfif>
<cfcatch type="any">
<cfset local.timezone = "">
</cfcatch>
</cftry>
<cfreturn local.timezone>
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment