CFLib.org – Common Function Library Project

convertActiveDirectoryTime(adTime)

Last updated September 6, 2006

Version: 1 | Requires: ColdFusion MX | Library: DateLib

 
Rated 0 time(s). Average Rating: 0

Description:
Time in Active Directory is stored in a 64 bit integer that keeps track of the number of 100-Nanosecond intervals which have passed since January 1, 1601 (not to be confused with EPOCH). The 64 bit value uses 2 32bit parts to store the time. This function simply takes that number, and converts it for easy use. Algorithm adapted from a House of Fusion posting from David Strong. Returns a structure with the following elements: date: mm/dd/yyyy formatted date. time: HH:mm formatted date. ts: Raw timestamp.

Return Values:
Returns a struct.

Example:

view plain print about
<cfset stADDateTime = convertActiveDirectoryTime("127944393687163952")>
<cfoutput>
The Date is #stADDateTime.Date# and the time is #stADDateTime.Time#. 
Or freestyle format of: #DateFormat(stADDateTime.ts,"MMDDYYYY")# #TimeFormat(stADDateTime.ts,"hh:mmtt")#
</cfoutput>

Parameters:

Name Description Required
adTime Time in ActiveDirectory format. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Converts Active Directory 100-Nanosecond time stamps.
 * 
 * @param adTime      Time in ActiveDirectory format. (Required)
 * @return Returns a struct. 
 * @author Tariq Ahmed (tariq@dopejam.com) 
 * @version 1, September 6, 2006 
 */

function convertActiveDirectoryTime(adTime) {
    var retVal = structNew();
    var tempTime = arguments.adTime / (60*10000000);
    retVal.ts = DateAdd('n',tempTime,'1/1/1601');
    retVal.ts = DateConvert("utc2Local", retVal.ts );
    retVal.date = Dateformat(retVal.ts,'mm/dd/yyyy');
    retVal.time = Timeformat(retVal.ts,'HH:mm');
    return retVal;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
12 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
30 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson