procedure TForm1.Button1Click(Sender: TObject);
var D1,D2:Tdatetime;
begin
D1:=Cobdate.DateTime;
showmessage(datetimetostr(d1));
showmessage(Formatdatetime('yyyy-mm-dd',d1)); //格式化后的日期!
end;
下面为FormatDatetime函数的帮助!
function FormatDateTime(const Format: string; DateTime: TDateTime): string;
Description
FormatDateTime formats the TDateTime value given by DateTime using the format given by Format. See Date-Time format strings for more information.
If the string specified by the Format parameter is empty, the TDateTime value is formatted as if a 'c' format specifier had been given.