如何取出时间0:01:11中的小时、分、秒[:)](45分)

  • 主题发起人 odbc1230
  • 开始时间
O

odbc1230

Unregistered / Unconfirmed
GUEST, unregistred user!
如何取出时间0:01:11中的小时、分、秒[:)]
 
decodedatetime
procedure DecodeTime(Time: TDateTime; var Hour, Min, Sec, MSec: Word);

Description

DecodeTime breaks the object specified as the Time parameter into hours, minutes, seconds, and milliseconds.
 
var
hh,mm,ss:string;
begin
hh:=copy(formatdatetime('hhmmss',now),1,2);
mm:=copy(formatdatetime('hhmmss',now),3,2);
ss:=copy(formatdatetime('hhmmss',now),5,2);
end;

沒測試過!


 
以下的代码,可以求出年、月、日、时、分、秒:
procedure TForm3.Button1Click(Sender: TObject);
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
DecodeTime(Present, Hour, Min, Sec, MSec);
edit1.text:=inttostr(year);
edit2.text:=inttostr(month);
...........
end;
给分吧。
 
多人接受答案了。
 
顶部