用FormatDateTime函数,可以将日期型数据按照指定的格式转换为字符串,例如:ShowMessage(Formatdatetime('yyyy-mm-dd hh:nn:ss,now)); function FormatDateTime(const Format: string; DateTime: TDateTime): string;DescriptionFormatDateTime formats the TDateTime value given by DateTime using the format given by Format.
function FormatDateTime(const Format: string; DateTime: TDateTime): string;DescriptionFormatDateTime formats the TDateTime value given by DateTime using the format given by Format.
也可以象Formatdatetime('hh:mm:ss',now);这种形式
procedure Tfrmdate.FormShow(Sender: TObject);
begin
DateSeparator :='-';
ShortDateFormat :='yyyy-mm-dd';
LongDateFormat := 'YYYY-MM-DD HH:MM:SS';
end;