var
a:tdatetime;
begin
       a:=now;
      showmessage(datetimetostr(a));
end;

解决方案 »

  1.   

    now包括日期和时间
    date包括日期
      

  2.   

    你把变量定义为Tdate,用now得到的就是日期,定义为Ttime得到的就是时间,定义为Tdatetime得到的就是日期加时间
      

  3.   

    DELPHI有时间控件,直接用就可以
      

  4.   

    行了,以上的答案基本都对,呵呵,用now和date函数可直接返回datetime类型,用datetimetostr函数可转为String类型
      

  5.   

    我想要精确一点的时间,至少要精确到秒,象Tsystemtime那样,Tdatetime只能到小时。Tsystem好像可以得到精确到秒的时间,但我不知道如何获得???谢谢!
      

  6.   


    可以用decodetime(now,HOURS,MINUTE,SECOND,MILLIONSECOND)
    当然,那几个大写的东西都是变量啦,变量值就是你要的东西啦!!
    可以精确到微秒!!
      

  7.   

    procedure TForm1.FormActivate(Sender: TObject);
    var
    systime:tsystemtime;
    begingetsystemtime(systime);edit1.text:=datetimetostr(systemtimetodatetime(systime));
    end;
      

  8.   

    用GetTickCount()取得是计算机多媒体时钟的时间,非常精确,能够到milliseconds级。不妨试一下!