红鱼儿

为FMX项目设置全局日期格式
  with FormatSettings do
  begin
    ShortDateFormat := 'yyyy-mm-dd';
    LongDateFormat :=  'yyyy-mm-dd';
    ShortTimeFormat := 'hh:nn:ss';
    LongTimeFormat := 'hh:nn:ss';
    DateSeparator := '-';
    TimeSeparator := ':';
  end;

加入项目源文件或者MainForm.onCreate中,这样以后的代码就都按这个格式处理了。

比如StrToDate('2020-01-01'),不会因为系统日期格式的不同而产生错误!

 

posted on 2022-04-28 15:20  红鱼儿  阅读(242)  评论(0编辑  收藏  举报