Delphi acquires Beijing (via Baidu and Timedate website)

Source: Internet
Author: User

Method One:

[Delphi]View Plaincopyprint?
  1. Uses
  2. Comobj, Dateutils;
  3. function Getinternettime: string;
  4. Var
  5. Xmlhttp:olevariant;
  6. Datetxt: string;
  7. Datelst:tstringlist;
  8. Mon: string;
  9. TIMEGMT, Getnettime:tdatetime;
  10. S: string;
  11. Begin
  12. XmlHttp: = Createoleobject (' microsoft.xmlhttp ');
  13. XmlHttp.  Open (' GET ', ' http://open.baidu.com/special/time/', False);
  14. XmlHttp.  Send;
  15. Datetxt: = XmlHttp.   getResponseHeader (' Date ');
  16. Datetxt: = Copy (Datetxt, Pos (', ', datetxt) + 1, 100);
  17. Datetxt: = StringReplace (Datetxt, ' GMT ', ', []);
  18. Datetxt: = Trim (Datetxt);
  19. If datetxt = "then Exit;
  20. Datelst: = Tstringlist.  Create;
  21. while Pos (", datetxt) > 0 do
  22. begin
  23. Datelst.  ADD (Copy (Datetxt, 1, Pos (', datetxt)- 1));
  24. Datetxt: = Copy (Datetxt, Pos (", datetxt) + 1, 100);
  25. end;
  26. Datelst.  ADD (Datetxt);
  27. if datelst[1] = ' Jan ' Then
  28. Mon: = ' Down '
  29. Else if datelst[1] = ' Feb ' Then
  30. Mon: = ' on '
  31. Else if datelst[1] = ' Mar ' Then
  32. Mon: = ' a '
  33. Else if datelst[1] = ' Apr ' Then
  34. Mon: = ' i '
  35. Else if datelst[1] = ' Mar ' Then
  36. Mon: = ' on '
  37. Else if datelst[1] = ' June ' Then
  38. Mon: = ' '
  39. Else if datelst[1] = ' Jul ' Then
  40. Mon: = ' '
  41. Else if datelst[1] = ' OK ' Then
  42. Mon: = ' A '
  43. Else if datelst[1] = ' Sep ' Then
  44. Mon: = ' the '
  45. Else if datelst[1] = ' Oct ' Then
  46. Mon: = ' Ten '
  47. Else if datelst[1] = ' Nov ' Then
  48. Mon: = ' One '
  49. Else if datelst[1] = ' Dec ' Then
  50. Mon: = ' 12 ';
  51. S: = datelst[2] + '-' + mon + '-' + datelst[0] + ' + datelst[3];
  52. Standard Time
  53. ShowMessage (s);
  54. '/' or '-'
  55. TIMEGMT: = Strtodatetime (datelst[2] + '-' + mon + '-' + datelst[0] + ' + datelst[3]);
  56. //Convert time zone
  57. Getnettime: = Inchour (TIMEGMT, 8);
  58. ShowMessage (FormatDateTime (' yyyy mm month dd HH:NN:SS ', getnettime));
  59. Freeandnil (DATELST);
  60. result:= formatdatetime (' yyyy mm month dd Day HH:NN:SS ', getnettime);
  61. End

Method Two:

[Delphi]View Plaincopyprint?
  1. Procedure TForm1.  Formcreate (Sender:tobject);
  2. Begin
  3. WebBrowser.  Navigate (' http://www.timedate.cn/worldclock/ti.asp ');
  4. TMR1.  Enabled: = True;
  5. End
  6. Procedure TForm1.  Webbrowserstatustextchange (Sender:tobject;
  7. const text:widestring);
  8. Var
  9. StrText: string;
  10. Begin
  11. StrText: = Text;
  12. If StrText = ' Done ' then
  13. begin
  14. Caption: = WebBrowser. OleObject. Document. Body.  Innertext;
  15. TMR1. Enabled: = True
  16. end;
  17. End
  18. Procedure TForm1Tmr1timer (sender:tobject);
  19. Begin
  20. TMR1.  Enabled: = False;
  21. WebBrowser. Refresh
  22. End

http://blog.csdn.net/yanjiaye520/article/details/7887463

Delphi acquires Beijing (via Baidu and Timedate website)

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.