Delphi Routine that retrieves the current time and date from a time server

advertisements

I am looking for a Delphi 7 routine which connects to a time server to retrieve the correct time and date, and a routine to update the time and date of the pc.

The routine should of course take into account the time zone the pc is using.

If possible using the ICS component suite from Overbyte (because I use this set of free components for html and ftp access already). But if not, any solution would be appreciated.

Thanks in advance.


Take a look at Indy's IdDayTime component. Point it to your favourite time server and check the DayTimeStr property.

  IdDayTime1.Host := 'time-a.nist.gov';
  Label1.Caption := IdDayTime1.DayTimeStr;

Edit: The result is in UTC time, so you'll probably need to convert it.