Getting current system time and date... - Programmers Heaven

Howdy, Stranger!

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

Categories

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.