SocketTools .NET Edition

NetworkTime.GetTime Method (String)

Get the current date and time from the specified time server.

[Visual Basic]
Overloads Public Function GetTime( _
   ByVal hostName As String _
) As Date
[C#]
public DateTime GetTime(
   string hostName
);

Parameters

hostName
A string which specifies the host name or IP address of the time server.

Return Value

This method returns a System.DateTime value which specifies the date and time provided by the server. If the method fails, the return value is System.DateTime.MinValue. To get extended error information, check the value of the LastError property.

Remarks

Time servers are commonly maintained by governments and universities. If you are unable to obtain the time from a server, contact the system administrator to determine if they have the standard time service available on port 37 or 123.

In the United States, the National Institute of Standards and Technology (NIST) hosts public servers which can be used to obtain the current time. It is recommended most applications use time.nist.gov as the server. Public servers should not be queried frequently and may block multiple requests issued over a short period of time.

See Also

NetworkTime Class | SocketTools Namespace | NetworkTime.GetTime Overload List