简单问题请教
请教如何获得当前的年份,月份,日期,并转换成string类型?
谢谢!

解决方案 »

  1.   

    function date:tadatetime
    function time:tdatetime
    datetimetostr(date+time);
      

  2.   

    function date:tdatetime
    function time:tdatetime
    datetimetostr(date+time);
      

  3.   

    var
       hh,mm,ss,mss:word;
        tm:tdatetime;
    begin
       tm:=now;
        decodetime(tm,hh,mm,ss,mss);
        edit1.Text:=timetostr(tm)+' '+inttostr(mss);//mms是毫秒
    end;
      

  4.   

    我是要得到具体的月份,比如现在是十月,要得到sting类型的 '10'
    不是楼上说的那种组合的string格式
      

  5.   

    不好意思,我看错题了,我写的那个是当前的系统时间。
    再来一次:
     var
       tm:tdatetime;
       
    begin
       tm:=date;//如果把date改为now会在原来的基础上加上时间
       edit1.text:=datetimetostr(tm);end;
      

  6.   

    谢谢楼上几位,可能还是没讲清楚,我要得到系统当前的月份是几月?
    比如现在是十月,我要得到string类型的'10',分别得到月份,年份两个string.
      

  7.   

    function getsystemtime:tsystemtime
    tsystemtime=record
      year:word;
      month:word;
      day:word;
      hour
      min
      sec
      weekofday
    end;
      
      

  8.   

    var
       tm:tdatetime;
       year,month,day:word;
    begin
       tm:=date;
       decodedate(tm,year,month,day);
       edit1.text:=inttostr(year);
       edit2.text:=inttostr(month);
       edit3.text:=inttostr(day);
    end;
      

  9.   

    谢谢lovedata(萨菲洛斯),这次已经可以了,也谢谢楼上几位!