str:=formatdatetime(now,'yyyy-mm-dd hh:mm:ss');
解决方案 »
- ado访问ACCESS数据库时,ADOdataset结合ADOCONNECTION速度快吗?
- DevExpress 系列组件汉化 by sunzscom,缺少英文原版,特别Grid 4.5.2,谁有的话帮帮我
- 请问如何查询出数据库中某字段后一部份的最大值?请进来帮帮忙.
- 如何取的机器的 hostid?
- 在线等待,记录型动态数组问题!!!!
- 紧急求助delphi中用excel做报表的问题
- MIDAS更新时出现"不能在手动或分布事务方式下创建新的连接"错误是何故?
- 如果有这样一本书??up有分!!!
- 请高手简单谈谈delphi和oracle8~!
- 关于用ODBC访问Excel
- 请问如何动态改变TCHART 的数值?用以动态赋值?
- 寻找帮手,有南京的delphi程序员吗?
str:=formatdatetime('yyyy-mm-dd hh:mm:ss',now);
我不是要获取当前日期时间,就是要把上述的日期时间字符串转换成那个格式另外:这是从邮件头中提取的日期时间,邮件的日期时间一般都是这个格式吗?
会不会不同类型的mail server生成的格式不一样?
d:tdatetime;
begin
d:=StrInternetToDateTime(Tue, 7 Aug 2001 17:52:16 +0800);
edit2.Text:=formatdatetime('yyyy-mm-dd hh:mm:ss',d);
end;
对了indy带源码吗
indy是有源码的,在Delphi6\Source\Indy下,我可无法完全从中摘出这个函数的代码,只能简单搞一下了。
function RawStrInternetToDateTime(var Value: string): TDateTime;
var
i: Integer;
Dt, Mo, Yr, Ho, Min, Sec: Word;
sTime: string;
begin
Result := 0.0;
Value := Trim(Value);
if length(Value) = 0 then
begin
Exit;
end; try
if StrToDay(Copy(Value, 1, 3)) > 0 then
begin
Fetch(Value);
end;
Dt := StrToIntDef(Fetch(Value), 1);
Value := TrimLeft(Value);
Mo := StrToMonth(Fetch(Value));
Value := TrimLeft(Value);
Yr := StrToIntDef(Fetch(Value), 1900);
if Yr < 80 then
begin
Inc(Yr, 2000);
end
else
if Yr < 100 then
begin
Inc(Yr, 1900);
end; Result := EncodeDate(Yr, Mo, Dt);
Value := TrimLeft(Value);
i := IndyPos(':', Value); {do not localize}
if i > 0 then
begin
sTime := fetch(Value, ' '); {do not localize}
Ho := StrToIntDef(Fetch(sTime, ':'), 0); {do not localize}
Min := StrToIntDef(Fetch(sTime, ':'), 0); {do not localize}
Sec := StrToIntDef(Fetch(sTime), 0);
Result := Result + EncodeTime(Ho, Min, Sec, 0);
end;
Value := TrimLeft(Value);
except
Result := 0.0;
end;
end;
function StrInternetToDateTime(Value: string): TDateTime;
begin
Result := RawStrInternetToDateTime(Value);
end;