Delphi使用XmlHttp获取时间
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)+,);
datetxt := StringReplace(datetxt,'GMT','',[]);
datetxt := Trim(datetxt);
DateLst := TStringList.Create;
while Pos(' ',datetxt)> do
begin
DateLst.Add(Copy(datetxt,,Pos(' ',datetxt)-)) ;
datetxt := Copy(datetxt,Pos(' ',datetxt)+,);
end ;
DateLst.Add(datetxt) ;
if DateLst[] = 'Jan' then
mon := ''
else if DateLst[] = 'Feb' then
mon := ''
else if DateLst[] = 'Mar' then
mon := ''
else if DateLst[] = 'Apr' then
mon := ''
else if DateLst[] = 'Mar' then
mon := ''
else if DateLst[] = 'Jun' then
mon := ''
else if DateLst[] = 'Jul' then
mon := ''
else if DateLst[] = 'Aug' then
mon := ''
else if DateLst[] = 'Sep' then
mon := ''
else if DateLst[] = 'Oct' then
mon := ''
else if DateLst[] = 'Nov' then
mon := ''
else if DateLst[] = 'Dec' then
mon := '' ;
timeGMT := StrToDateTime(DateLst[]+'-'+mon+'-'+DateLst[]+' '+ DateLst[]);
GetNetTime := IncHour(TimeGMT,);
self.Caption := FormatDateTime('yyyy年mm月dd日 HH:NN:SS',GetNetTime) ;
end;
http://www.lsworks.net/article/20.html
Delphi使用XmlHttp获取时间的更多相关文章
- ajax异步服务器获取时间
1.创建ajax对象 <script type="text/javascript"> //创建AJAX异步对象 function createAJAX(){ var a ...
- javaScript系列:js中获取时间new Date()详细介绍
var myDate = new Date();myDate.getYear(); //获取当前年份(2位)myDate.getFullYear(); //获取完整的年份(4位,1970-????)m ...
- [moka同学笔记]php 获取时间(今天,昨天,三天内,本周,上周,本月,三年内,半年内,一年内,三年内)
<?php /** * php 获取时间(今天,昨天,三天内,本周,上周,本月,三年内,半年内,一年内,三年内) * * author:ihelloworld2010@gmail.com * d ...
- PHP获取时间、时间戳的各种格式
1.获取当前时间方法date() 很简单,这就是获取时间的方法,格式为:date($format, $timestamp),format为格式.timestamp为时间戳--可填参数. 2.获取时间戳 ...
- 单位换算(格式化十进制数-B),获取时间工具类CommenUtil
package com.example.administrator.filemanager.utils;import java.text.DecimalFormat;import java.text. ...
- 使用PHP获取时间今天 明天 昨天 时间戳的详解
使用php获取时间今天明天昨天时间戳 2013-06-20 11:12 <?php echo "今天:".date("Y-m-d")."< ...
- (基础篇)PHP获取时间、时间戳的各种格式写法汇总
1.获取当前时间方法date() 很简单,这就是获取时间的方法,格式为:date($format, $timestamp),format为格式.timestamp为时间戳–可填参数. 2.获取时间戳方 ...
- 【转载】c/c++在windows下获取时间和计算时间差的几种方法总结
一.标准C和C++都可用 1.获取时间用time_t time( time_t * timer ),计算时间差使用double difftime( time_t timer1, time_t time ...
- js(jQuery)获取时间的方法及常用时间类搜集
获取时间的方法及常用时间类都是大家经常使用的,在本文为大家整理了一些,个人感觉还比较全,感兴趣的朋友可以收集下 复制代码代码如下: $(function(){ var mydate = new D ...
随机推荐
- php 代码重用
<?php /* 21.php * 代码重用 * include() required()载入文件 * include() 如果载入文件不存在,提示警告,还可以继续执行 * required() ...
- 检测android的网络链接状态
http://www.oschina.net/question/100267_61129?sort=default&p=1#tags_nav http://www.cnblogs.com/to ...
- Go语言(golang)开源项目大全
转http://www.open-open.com/lib/view/open1396063913278.html内容目录Astronomy构建工具缓存云计算命令行选项解析器命令行工具压缩配置文件解析 ...
- Linux常用C函数---字符串转换篇
函数讲解部分参考http://net.pku.edu.cn/~yhf/linux_c/ atof(将字符串转换成浮点型数) 相关函数 atoi,atol,strtod,strtol,strtoul 表 ...
- poj 1603 Risk_spfa向前星
poj终于到100题,贴个代码纪念一下,hdu 到400题再贴 题意:有20个城市,接下来有19行告诉你,i城市与n个城市相连,图是双向的,然后叫你求x到y的最小经过几个城市 #include < ...
- Makefile与shell脚本区别
http://blog.chinaunix.net/uid-20672257-id-3345593.html 在Makefile可以调用shell脚本,但是Makefile和shell脚本是不同的.本 ...
- HDFS的运行原理(转载)
原文地址:http://www.cnblogs.com/laov/p/3434917.html 简介 HDFS(Hadoop Distributed File System )Hadoop分布式文件系 ...
- public void Delete<T>(List<T> EntityList) where T : class, new() 这是什么意思
就是说T必须是一个类(class)类型,不能是结构(structure)类型. 这是类型参数约束,.NET支持的类型参数约束有以下五种: where T : struct ...
- magent编译安装及常见错误
安装magent到/usr/local/下 cd /usr/local mkdir magent cd magent/ wget http://memagent.googlecode.com/file ...
- ps怎样选取自己想要的图片部分(二)
上篇文章我们介绍了怎样选取所要的图形.但往往我们实际做项目的时候须要创建一个圆形图标或者椭圆形图标,这样会使得我们的图标相比矩形图标更加美观一些. 那么怎样将一个矩形图标改成圆形图标呢? 首先我们须要 ...