方法1:
procedure TForm1.btn1Click(Sender:TObject);
var s:string;
begin
//yyyy-mm-dd後面帶了一個空格,為了拼上time時格式正确
s:=FormatDateTime('yyyy-mm-dd ',dtp1.Date) + FormatDateTime('hh:mm:ss',dtp2.Time);
end;
方法2:
procedure TForm1.btn1Click(Sender:TObject);
var s:string;
begin
//date、time值合并到一個控件。
dtp1.Time:=dtp2.Time;
s:=FormatDateTime('yyyy-mm-dd hh:mm:ss',dtp1.DateTime);
end;