如何在Delphi中格式化Unix时间戳? [英] How to format a Unix timestamp in Delphi?

查看:1160
本文介绍了如何在Delphi中格式化Unix时间戳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有

  var timestamp:Longint; 
timestamp:= Round((Now() - 25569.0 {Unix start date in Delphi terms})* 86400);

我在某些MySql中用作主键。



但是,我也想格式化日期/时间,例如 PHP的date()函数是的。



有没有人有代码片段或URL?

解决方案

您正在寻找

  function DateTimeToUnix(const AValue:TDateTime):Int64; 

  function UnixToDateTime(const AValue:Int64):TDateTime; 

来自DateUtils.pas的功能



TDateTime值可以通过 FormatDateTime 进行格式化 / p>

I have

var timestamp: Longint;  
timestamp := Round((Now() - 25569.0 {Unix start date in Delphi terms} ) * 86400);

which I am using as a primary key in some MySql stuff.

But I would also like to format the date/time, like PHP's date() function does.

Does anyone have a code snippet or URL?

解决方案

You are looking for

function DateTimeToUnix(const AValue: TDateTime): Int64;

and

function UnixToDateTime(const AValue: Int64): TDateTime;

functions from DateUtils.pas

TDateTime value can be formatted by FormatDateTime function

这篇关于如何在Delphi中格式化Unix时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆