Method One:
Uses Comobj, dateutils;
function getinternettime:string;
var xmlhttp:olevariant;
datetxt:string;
Datelst:tstringlist;
mon:string;
TIMEGMT, Getnettime:tdatetime;
s:string;
Begin XmlHttp: = Createoleobject (' microsoft.xmlhttp ');
Xmlhttp.open (' GET ', ' http://open.baidu.com/special/time/', False);
Xmlhttp.send;
Datetxt: = Xmlhttp.getresponseheader (' Date ');
Datetxt: = Copy (Datetxt, Pos (', ', datetxt) + 1, 100);
Datetxt: = StringReplace (Datetxt, ' GMT ', ', []);
Datetxt: = Trim (Datetxt);
If Datetxt = "then Exit;
Datelst: = tstringlist.create;
While Pos (", datetxt) > 0 do begin Datelst.add (Copy (datetxt, 1, Pos (', datetxt)-1));
Datetxt: = Copy (Datetxt, Pos (", datetxt) + 1, 100);
End
Datelst.add (Datetxt); If datelst[1] = ' Jan ' then mon: = ' datelst[1 ' and ' If ' (') ' then mon: = ' ' else if datelst[1] = ' Mar ' Then mon: = ' datelst[1 ' else if datelst[1] = ' April ' then mon: = ' ' else if] = ' Mar ' tHen Mon: = ' else if datelst[1] = ' June ' then mon: = ' else if datelst[1] = ' Jul ' then mon: = ' 07 ' else if datelst[1] = ' datelst[1 ' then mon: = ' or ' else if] = ' Sep ' then mon: = ' ' else if datelst[1] = ' Oct ' then mon: = ' else if datelst[1] = ' Nov ' then mon: = ' one ' else if datelst[1] = ' Dec ' then mon: = '
12 ';
S: = datelst[2] + '-' + mon + '-' + datelst[0] + ' + datelst[3];
Standard Time//ShowMessage (s);
'/' or '-' timegmt: = Strtodatetime (datelst[2] + '-' + mon + '-' + datelst[0] + ' + datelst[3]);
Convert time zone Getnettime: = Inchour (TIMEGMT, 8);
ShowMessage (FormatDateTime (' yyyy mm month dd HH:NN:SS ', getnettime));
Freeandnil (DATELST);
result:= formatdatetime (' yyyy mm month dd Day HH:NN:SS ', getnettime);
End
Method Two:
Procedure Tform1.formcreate (sender:tobject);
Begin
Webbrowser.navigate (' http://www.timedate.cn/worldclock/ti.asp ');
Tmr1. Enabled: = True;
End;
Procedure Tform1.webbrowserstatustextchange (sender:tobject;
const text:widestring);
var
strtext:string;
Begin
StrText: = Text;
If StrText = ' done ' then
begin
Caption: = WebBrowser.OleObject.Document.Body.Innertext;
Tmr1. Enabled: = True
end;
End;
Procedure Tform1.tmr1timer (sender:tobject);
Begin
TMR1. Enabled: = False;
Webbrowser.refresh
end;