uses System.DateUtils; function TForm1.Gettamptime(vlen: Integer): string; var ss: string; begin if vlen = 13 then begin ss := DateTimeToTimeStamp(now).time.ToString; Result := IntToStr(DateTimeToUnix(Now, false)) + Copy(ss, Length(ss) - 2, Length(ss)); end else if vlen = 10 then begin Result := IntToStr(DateTimeToUnix(Now, false)); end end; function TForm1.GettampToTime(vtamp: string): string; 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;
中年大叔学Delphi
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步