Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created March 25, 2014 10:40
Converting To And From GMT / UTC Time In ColdFusion Using DateConvert()
<!--- Get the current time. --->
<cfset dtNow = Now() />
<!---
Convert the date to GMT using DateAdd() and DateConvert()
to make sure that they are the same.
--->
DateAdd(): #DateAdd( "s", GetTimeZoneInfo().UTCTotalOffset, dtNow )#
<br />
DateConvert(): #DateConvert( "Local2UTC", dtNow )#
<br />
<!--- Get the GMT time. --->
<cfset dtGMT = ParseDateTime(
GetHTTPTimeString( Now() )
) />
<!--- Convert from GTM back to local time. --->
Now: #Now()#
<br />
DateConvert(): #DateConvert( "UTC2Local", dtGMT )#
<br />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment