unit GetInternetTime; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComObj, DateUtils; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private public function GetInternetTime:string; end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var InternetTime:string; begin InternetTime:=GetInternetTime; ShowMessage(InternetTime); end; function TForm1 .GetInternetTime:string; var XmlHttp: Variant; datetxt: string; DateLst: TStringList; mon: string; timeGMT, GetNetTime: TDateTime; s: string; begin XmlHttp := CreateOleObject('Microsoft.XMLHTTP'); XmlHttp.Open('Get', 'http://www.baidu.com/', False); XmlHttp.send; datetxt := XmlHttp.getResponseHeader('Date'); datetxt := Copy(datetxt, Pos(',', datetxt) + 1, 100); datetxt := StringReplace(datetxt, 'GMT', '', []); datetxt := Trim(datetxt);