I have
var timestamp: Longint;
timestamp := Round((Now() - 25569.0 {Unix start date in Delphi terms} ) * 86400);
which I am using as a prima
I would use DateTimeToUnix
, as suggested by @kludg.
function DateTimeToUnix(const AValue: TDateTime): Int64;
In case you want the current Unix timestamp in milliseconds format, you can implement the following function:
function UNIXTimeInMilliseconds: Int64;
var
DateTime: TDateTime;
SystemTime: TSystemTime;
begin
GetSystemTime(SystemTime);
DateTime := SysUtils.EncodeDate(SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay) +
SysUtils.EncodeTime(SystemTime.wHour, SystemTime.wMinute, SystemTime.wSecond, SystemTime.wMilliseconds);
Result := DateUtils.MilliSecondsBetween(DateTime, UnixDateDelta);
end;