• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

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
0
mantra246
Asked:
mantra246
2 Solutions
 
StevenBCommented:
The function is effectively:


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

or:

  Result := AValue / 86400 + 693594;


It should be fairly trival to convert this to VBScript or whatever else
0
 
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)
0
 
TheRealLokiSenior DeveloperCommented:
function UnixTimeToDateTime(const UnixTime: Integer): TDateTime;
var
    f: TFileTime;
    s: TSystemTime;
    i: Int64;
begin
    i := (Int64(UnixTime) * Int64(10000000)) + 116444736000000000;
    f.dwLowDateTime := DWORD(i);
    f.dwHighDateTime := i shr 32;
    FileTimeToSystemTime(f, s);
    Result := SystemTimeToDateTime(s);
end;
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now