Delphi获取Unix当前系统时间戳
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
Str := IntToStr(DateTimeToTimeStamp(Now).Date) + '' + IntToStr(DateTimeToTimeStamp(now).time);
ShowMessage(InttoStr(DateTimeToUnixDate(now)));
end;
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
Str := IntToStr(DateTimeToTimeStamp(Now).Date) + '' + IntToStr(DateTimeToTimeStamp(now).time);
ShowMessage(InttoStr(DateTimeToUnixDate(now)));
end;
宝剑锋从磨砺出,
梅花香自苦寒来。