getNISTTime([timeServer])
Last updated December 07, 2005
Version: 1 | Requires: CF6 | Library: UtilityLib
Description:
Obtains current time data from NIST Internet Time Service servers.
Return Values:
Returns a structure.
Example:
<cfdump var="#getNISTTime()#">
Parameters:
Name | Description | Required |
---|---|---|
timeServer | Time server. Defaults to 192.43.244.18. | No |
Full UDF Source:
<!---
Obtains current time data from NIST Internet Time Service servers.
@param timeServer Time server. Defaults to 192.43.244.18. (Optional)
@return Returns a structure.
@author Ben Forta (ben@forta.com)
@version 1, December 7, 2005
--->
<cffunction name="GetNISTTime" returntype="struct" output="false">
<cfargument name="timeServer" type="string" default="192.43.244.18" required="false">
<cfset var result=StructNew()>
<!--- Try/catch block --->
<cftry>
<!--- Try get time data --->
<cfhttp url="http://#arguments.timeServer#:13/" />
<!--- Save raw data --->
<cfset result.raw = CFHTTP.FileContent>
<!--- Extract Julian date --->
<cfset result.julian=ListGetAt(result.raw, 1, " ")>
<!--- Extract current date and time --->
<cfset result.now=ParseDateTime(ListGetAt(result.raw, 2, " ")
& " "
& ListGetAt(result.raw, 3, " "))>
<!--- Extract daylight savings time flag --->
<cfset result.dst=IIf(ListGetAt(result.raw, 4, " ") IS 0,
FALSE, TRUE)>
<!--- Extract leap month flag --->
<cfset result.leapmonth=IIf(ListGetAt(result.raw, 5, " ") IS 0,
FALSE, TRUE)>
<!--- Extract health flag --->
<cfset result.healthy=IIf(ListGetAt(result.raw, 6, " ") IS 0,
FALSE, TRUE)>
<!--- Extract advance milliseconds --->
<cfset result.msadv=ListGetAt(result.raw, 7, " ")>
<!--- Success --->
<cfset result.success=TRUE>
<!--- Catch any errors --->
<cfcatch type="any">
<cfset result.success=FALSE>
</cfcatch>
</cftry>
<cfreturn result>
</cffunction>
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016