Einzelnen Beitrag anzeigen

Proddi

Registriert seit: 4. Sep 2003
9 Beiträge
 
#1

Aktuelle Systemzeit als UnixTime(-Stamp)

  Alt 4. Sep 2003, 14:45
Für alle die, die die aktuelle Systemzeit als Unix-Timestamp brauchen:
Daraus lässt sich nat. auch eine beliebige Zeit in UnixTime wandeln...
Delphi-Quellcode:
function GetUnixTime: int64;
var
  st:_SYSTEMTIME;
  ft:_FILETIME;
begin
  // first get windows SYSTEMTIME in UTC / GMT
  GetSystemTime(st);
  // now convert to windows FILETIME
  SystemTimeToFileTime(st, ft);
  // now to UNIXTIME
  result := round((int64(ft) - int64(116444736000000000)) / 10000000);
end;
[edit=Daniel B]Delphi-Tags korrigiert. Mfg, Daniel B[/edit]
[edit=Chakotay1308]Funktion korrigiert. Mfg, Chakotay1308[/edit]
[edit=Matze]Code formatiert. Mfg, Matze[/edit]
[edit=Chakotay1308]Klassifizierung. Mfg, Chakotay1308[/edit]
[edit=fkerber]Neu abgespeichert wg. Code-Highlighting. Mfg, fkerber[/edit]
  Mit Zitat antworten Zitat