Date and Time Conversion

Does anyone have idea on how to convert a unix type date and time WITHOUT using any of the delphi sysutils routines?

The reason i don;t want to use the systutils routines is that i want to be able to easily convert the code to other languages that use (ie: VBScript)

Example Date and Time is: 1115721150
Who is Participating?
The function is effectively:

  Result := AValue / (24 * 60 * 60) + 693594;


  Result := AValue / 86400 + 693594;

It should be fairly trival to convert this to VBScript or whatever else
mantra246Author Commented:
using 1115721150 div 86400 + 693594 gives a result of 706507.

I was looking for more a date and time - in any format (ie: mmddyy hhmmss OR ddmmyy hhmm)
TheRealLokiConnect With a Mentor Senior DeveloperCommented:
function UnixTimeToDateTime(const UnixTime: Integer): TDateTime;
    f: TFileTime;
    s: TSystemTime;
    i: Int64;
    i := (Int64(UnixTime) * Int64(10000000)) + 116444736000000000;
    f.dwLowDateTime := DWORD(i);
    f.dwHighDateTime := i shr 32;
    FileTimeToSystemTime(f, s);
    Result := SystemTimeToDateTime(s);
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.