首页 > 技术文章 > delphi '20210806'转'2021-08-06'

redhat588 2021-08-06 16:45 原文

function StrtoDate(Astr: string): string;
var
  D: TDateTime;
  s: string;
begin
   //'20210806'转'2021-08-06'
  // uses System.StrUtils
  s := StuffString(StuffString(Astr, 5, 0, '-'), 8, 0, '-');
  D := VarToDateTime(s);
  Result := FormatDatetime('M-dd', D);
end;

 

推荐阅读