function TForm1.RecoverDateFrom1970Sec(const aSecNum: Cardinal): TDateTime;
begin
  result := 1.0 * aSecNum /86400.00 + 25569;
end;
用上面这个可以把秒转化成具体的时间,那么怎么把转化后的时间格式(如2011-08-22 03:16:00)在转化回去???我新手 麻烦给出代码 

解决方案 »

  1.   

    字符串格式的时间?  sDate := '2011-08-22 03:16:00';
      FormatSet.ShortDateFormat := 'yyyy-mm-dd';
      FormatSet.LongTimeFormat := 'hh:nn:ss';
      FormatSet.TimeSeparator := ':';
      FormatSet.DateSeparator := '-';
      StrToDateTimeDef(sDate, 0, FormatSet);//字符串转为时间格式
      

  2.   

    (a - 25569) * 86400.00 ---得到时间的 ,然后赋值给时间对象, 通过Format来格式化输出
      

  3.   

    很简单的:
    d: TDateTime;
    f: Double;
    n: Integer;
      d := RecoverDateFrom1970Sec(1234567);
      f := d;
      n := Floor((f - 25569) * 86400);
      
    结果n=1234567
    其中Floor是系统函数库math的函数,你需要加入到uses里面
      

  4.   

    其实DELPHI中有函数的,你还是看看基础知识吧
    很简单的