Delphi acquires Beijing-GMT

Source: Internet
Author: User

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;



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.