求助:请问如何在Delphi中把时间格式设为:HH:mm:ss,
短日期格式设为:YYYY-MM-DD.
用我的方法设了后,如系统原来是:H:MM:SS,我在程序中设为HH:MM:SS后.退出应用程序后要出错.

解决方案 »

  1.   

    用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.
      

  2.   

    Formatdatetime('yyyy-mm-dd hh:mm:ss',now);这是完整的
    也可以象Formatdatetime('hh:mm:ss',now);这种形式
      

  3.   

    可以这样设置:
    procedure Tfrmdate.FormShow(Sender: TObject);
    begin
       DateSeparator :='-';
       ShortDateFormat :='yyyy-mm-dd';
       LongDateFormat := 'YYYY-MM-DD HH:MM:SS';
    end; 
      

  4.   

    Formatdatetime('yyyy-mm-dd hh:mm:ss',now);