Date and Time Conversion

Posted on 2005-05-10
Last Modified: 2010-04-05
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
Question by:mantra246
    LVL 5

    Expert Comment

    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

    Author Comment

    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)
    LVL 11

    Accepted Solution

    LVL 17

    Assisted Solution

    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);

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
    Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now