CFLib.org – Common Function Library Project

parseGeneralizedTimeString(timeString)

Last updated December 16, 2005

author

Michael Dawson

Version: 1 | Requires: CF5 | Library: DateLib

Description:
Microsoft's Active Directory stores a generalized time string in many of its attributes. ColdFusion cannot natively parse this time string. This function adds date and time delimiters to the time string to allow ColdFusion to correctly parse the value. This function does not calculate any time zone offset since Active Directory does not store that information. This function also does not convert the time from UTC to local.

Return Values:
Returns a date object.

Example:

<cfset weddingTime = "19880923191500.0Z">

<cfoutput>
I was married on #parseGeneralizedTimeString(weddingTime)#.
</cfoutput>

Parameters:

Name Description Required
timeString Generalized time string. Yes

Full UDF Source:

/**
 * Creates a date/time object from a generalized time string in the format of YYYYMMDDHHMMSS.0Z
 * 
 * @param timeString 	 Generalized time string. (Required)
 * @return Returns a date object. 
 * @author Michael Dawson (md40@evansville.edu) 
 * @version 1, December 16, 2005 
 */
function parseGeneralizedTimeString(timeString){
	// This function expects a generalize time string in the following format: 19880923191500.0Z

	// Return the parsed date/time object.
	return parseDateTime(left(arguments.timeString, 4) & "-" & mid(arguments.timeString, 5, 2) & "-" & mid(arguments.timeString, 7, 2) & " " & mid(arguments.timeString, 9, 2) & ":" & mid(arguments.timeString, 11, 2) & ":" & mid(arguments.timeString, 13, 2));
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson