啦啦啦,拿去用,不谢
//获取13或10位时间戳
function Gettamptime(vlen: Integer): string;
var
timen, time2: TDateTime;
ss2, ss3: Int64;
begin
timen := now;
time2 := EncodeDateTime(1970, 1, 1, 0, 0, 0, 0);
ss2 := 28800000;
ss3 := MilliSecondsBetween(timen, time2);
ss3 := ss3 - ss2;
Result := InttoStr(ss3);
if vlen = 13 then
Result := Result
else if vlen = 10 then
Result := Copy(Result, 1, 10);
end;
//转位普通时间
function gettamptotime(vtamp: string): string;
//1582688206607
var
ls10,lms: string;
begin
if Length(vtamp) = 10 then
Result := FormatDateTime('yyyy-MM-dd hh:mm:ss',UnixToDateTime(StrToInt64(vtamp),false))
else if Length(vtamp) = 13 then
begin
ls10 := Copy(vtamp,1,10);
lms := Copy(vtamp,11,13);
Result := FormatDateTime('yyyy-MM-dd hh:mm:ss',UnixToDateTime(StrToInt64(ls10),false));
Result := Result +'.' + lms;
end;
end;