Преобразовать TDateTime в Unix TimeStamp



Оформил: DeeCo
Автор: http://www.swissdelphicenter.ch

{
Sometimes you want to communicate with mySQL or other databases using
the unix timestamp. To solve this difference you may want to convert your
TDateTime to the unix timestamp format and vice versa.
Um den in einigen Datenbanken verwendeten Unix Timestamp fur die Kommunikation
mit Delphi nutzbar zu machen, kann man mit dieser Unit das TDateTime Format
in den Unix Timestamp und umgekehrt umwandeln.
}
unit unix_utils;
interface
implementation
const
// Sets UnixStartDate to TDateTime of 01/01/1970 
UnixStartDate: TDateTime = 25569.0;
function DateTimeToUnix(ConvDate: TDateTime): Longint;
begin
//example: DateTimeToUnix(now); 
Result := Round((ConvDate - UnixStartDate) * 86400);
end;
function UnixToDateTime(USec: Longint): TDateTime;
begin
//Example: UnixToDateTime(1003187418); 
Result := (Usec / 86400) + UnixStartDate;
end;
end.

Далее: Преобразовать TFileTime в TDateTime »»