时间戳,秒级,毫秒级转换DateTime格式
作者:互联网
解决了本地时间和格林尼治时间差问题
function DateTimeToTimeStamp(ConvDate: TDateTime): time_t;
var
zi: TTimeZoneInformation;
begin
GetTimeZoneInformation(zi);
Result := Round((ConvDate - UnixDateDelta) * 86400) + 60 * (zi.Bias + zi.DaylightBias);
end;
function TimeStampToDateTime(USec: time_t): TDateTime;
var
zi: TTimeZoneInformation;
begin
GetTimeZoneInformation(zi);
Result := ((USec - 60 * zi.Bias) / 86400) + UnixDateDelta;
end;
标签:function,zi,ConvDate,DateTime,60,毫秒,TDateTime,秒级,TTimeZoneInformation 来源: https://www.cnblogs.com/zyb2016/p/11088176.html