function UnixTimeStampToDateTimeStr(UnixTimeStamp: Int64): string;
var
  DateTimeValue: TDateTime;
begin
  //第二个参数 默认为true,设置为false,会默认以本地时区来 + 8小时,因为mysql里村的utc时间 秒数
  DateTimeValue := UnixToDateTime(UnixTimeStamp  div 1000, False);
  // 如果你需要特定的格式,比如 yyyy-mm-dd hh:mm:ss,你可以这样:
  Result := FormatDateTime('yyyy-mm-dd hh:mm:ss', DateTimeValue);
end;


procedure TForm2.Button2Click(Sender: TObject);
begin
  ShowMessage(UnixTimeStampToDateTimeStr(1713693812742));
end;

image

posted on 2024-04-24 15:15  del88  阅读(5)  评论(0编辑  收藏  举报