A developer asked me how he could get absolutely accurate time information for an application that he is working on. He cannot rely on local server time as he has no control over the machine, and can’t verify that it is accurate (and can’t change the time if not). There is no NTP (network time protocol) tag in ColdFusion, but fortunately one is not needed, because the NIST time servers also respond to plain text daytime protocol requests.
Here is a quick UDF I threw together to solve the problem. Call GetNISTTime() and it’ll return a structure containing the raw data returned from the time server, as well as individual fields broken out for ease of use:
To test this code you can just use:
Leave a Reply