function DateTimeToUnix(ConvDate: TDateTime;Len:integer=10): string;
var
zi : TTimeZoneInformation;
unixtime:Int64;
ATimeStamp: TTimeStamp;
timezzz:string;
begin
GetTimeZoneInformation(zi);
unixtime := Round((ConvDate - UnixDateDelta) * 86400) + 60*(zi.Bias + zi.DaylightBias);
Result := IntToStr(unixtime);
if Len=13 then
begin
ATimeStamp := DateTimeToTimeStamp(ConvDate);
timezzz := IntToStr(ATimeStamp.Time);
timezzz := Copy(timezzz,Length(timezzz)-2,Length(timezzz));
Result := Result+timezzz;
end;
end;
function UnixToDateTime(USec: string;len:integer=10): string;
var
zi : TTimeZoneInformation;
atime:Int64;
adatetime:TDateTime;
begin
atime := StrToInt64(Copy(USec,1,10));
GetTimeZoneInformation(zi);
adatetime := ((atime - 60*zi.Bias) / 86400) + UnixDateDelta;
Result := FormatDateTime('yyyy-dd-mm hh:mm:ss', adatetime);
if Length(USec) = 13 then
Result := FormatDateTime('yyyy-dd-mm hh:mm:ss', adatetime)+'.'+Copy(USec,11,13);
end;
// 最后附上 时间戳验证地址 : 时间戳(Unix timestamp)转换工具 - 在线工具