标签:
uses ComObj, DateUtils; procedure TForm1.Button1Click(Sender: TObject); var XmlHttp: Variant; datetxt : String; DateLst : TStringList; mon: String; timeGMT,GetNetTime:TDateTime; 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); 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 := ‘01‘ else if DateLst[1] = ‘Feb‘ then mon := ‘02‘ else if DateLst[1] = ‘Mar‘ then mon := ‘03‘ else if DateLst[1] = ‘Apr‘ then mon := ‘04‘ else if DateLst[1] = ‘Mar‘ then mon := ‘05‘ else if DateLst[1] = ‘Jun‘ then mon := ‘06‘ else if DateLst[1] = ‘Jul‘ then mon := ‘07‘ else if DateLst[1] = ‘Aug‘ then mon := ‘08‘ else if DateLst[1] = ‘Sep‘ then mon := ‘09‘ else if DateLst[1] = ‘Oct‘ then mon := ‘10‘ else if DateLst[1] = ‘Nov‘ then mon := ‘11‘ else if DateLst[1] = ‘Dec‘ then mon := ‘12‘ ; timeGMT := StrToDateTime(DateLst[2]+‘-‘+mon+‘-‘+DateLst[0]+‘ ‘+ DateLst[3]); GetNetTime := IncHour(TimeGMT,8); self.Caption := FormatDateTime(‘yyyy年mm月dd日 HH:NN:SS‘,GetNetTime) ; end;
http://www.lsworks.net/article/20.html
标签:
原文地址:http://www.cnblogs.com/findumars/p/4998996.html