Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Getting current system time and date...

Hi, i used to use the regular TP, andthere i use GETDATE(year,month,day,weekday); but thats in the dos unit, and delphi doesnt have it :-)
so... i need to find delpi's way to do it :-) i have searched thorugh the help thingy, but i couldnt find..

if anyone could help push me a little in the right direction? :-)

oh also, is there something in delphi (or some simple way) to compare 2 dates/times and check the date/time difference? (preferly in secs?)

Comments

  • ManningManning Posts: 1,621Member
    : Hi, i used to use the regular TP, andthere i use GETDATE(year,month,day,weekday); but thats in the dos unit, and delphi doesnt have it :-)
    : so... i need to find delpi's way to do it :-) i have searched thorugh the help thingy, but i couldnt find..
    :
    : if anyone could help push me a little in the right direction? :-)
    :
    : oh also, is there something in delphi (or some simple way) to compare 2 dates/times and check the date/time difference? (preferly in secs?)
    :

    Here is an example on how to get the system date and time:

    datetimetostring(s, 'dddd mmmm d, 2001 - h:nn:ssam/pm', now);
    showmessage(s);

    And if you have two dates in TDateTime format, you just subtract one from the other. That will get the number of days difference. If you multiply that by 86400 you will get the difference in seconds.

  • ManningManning Posts: 1,621Member
    : : Hi, i used to use the regular TP, andthere i use GETDATE(year,month,day,weekday); but thats in the dos unit, and delphi doesnt have it :-)
    : : so... i need to find delpi's way to do it :-) i have searched thorugh the help thingy, but i couldnt find..
    : :
    : : if anyone could help push me a little in the right direction? :-)
    : :
    : : oh also, is there something in delphi (or some simple way) to compare 2 dates/times and check the date/time difference? (preferly in secs?)
    : :
    :
    : Here is an example on how to get the system date and time:
    :
    : datetimetostring(s, 'dddd mmmm d, 2001 - h:nn:ssam/pm', now);
    : showmessage(s);
    :
    : And if you have two dates in TDateTime format, you just subtract one from the other. That will get the number of days difference. If you multiply that by 86400 you will get the difference in seconds.
    :

    Oops had a brain-fart there. 2001 should be yyyy to get the current 4 digit year.

  • WilcoChatWilcoChat Posts: 34Member

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls, IniFiles, ShellAPI, ComCtrls, ExtCtrls, Menus, OleCtrls,
    Spin, jpeg, ScktComp, IdTCPClient,
    IdBaseComponent, IdComponent, IdTCPConnection;

    resourcestring
    StatusDateTimeFormat = 'mm/dd/yyyy" - "hh:nn:ss AM/PM';



    were you want it to show:
    (' + FormatDateTime(StatusDateTimeFormat, Now) + ')



    that work i use it on my chat program

Sign In or Register to comment.