Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created March 25, 2014 00:37
Converting ISO Date/Time To ColdFusion Date/Time
<cffunction
name="ISOToDateTime"
access="public"
returntype="string"
output="false"
hint="Converts an ISO 8601 date/time stamp with optional dashes to a ColdFusion date/time stamp.">
<!--- Define arguments. --->
<cfargument
name="Date"
type="string"
required="true"
hint="ISO 8601 date/time stamp."
/>
<!---
When returning the converted date/time stamp,
allow for optional dashes.
--->
<cfreturn ARGUMENTS.Date.ReplaceFirst(
"^.*?(\d{4})-?(\d{2})-?(\d{2})T([\d:]+).*$",
"$1-$2-$3 $4"
) />
</cffunction>
<!---
Output the standard ColdFusion date/time stamp
for this XML RPC standards compliant ISO 8601
date/time stamp.
--->
#ISOToDateTime( "19980717T14:08:55" )#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment