delphi时间戳(10位)

procedure TForm1.btn4Click(Sender: TObject);
  var Str :String;  D :tDatetime;
  a:Double;
  function DateTimeToUnixDate(const ADate: TDateTime): Longint;
  const
  cUnixStartDate: TDateTime = 25569.333; // 1970/01/01
  begin
    Result := Round((ADate - cUnixStartDate) * 86400);
  end;
begin
   // D := StrToDateTime('2019-11-26 17:18:53');
   // a := D-18226.3881134;
   // ShowMessage(FloatToStr(a));
  Str := IntToStr(DateTimeToTimeStamp(Now).Date) + '' + IntToStr(DateTimeToTimeStamp(now).time);
  //Str := IntToStr(DateTimeToTimeStamp(now).Date);
  ShowMessage(InttoStr(DateTimeToUnixDate(now)));

end;

posted @ 2019-11-26 20:03  小美lmt  阅读(2134)  评论(0编辑  收藏  举报