С помощью компонентов:
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient, IdSNTP,
StdCtrls;
type
TForm1 = class(TForm)
IdSNTP1: TIdSNTP;
Button1: TButton;
procedure Button1Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(DateTimeToStr(IdSNTP1.DateTime));
end;
end.
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 293
ClientWidth = 426
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 24
Top = 72
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object IdSNTP1: TIdSNTP
Host = 'time2.stupi.se'
Port = 123
Left = 32
Top = 20
end
end