delphi '20210806'转'2021-08-06'

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;
中年大叔学Delphi
原文地址:https://www.cnblogs.com/redhat588/p/15109357.html