How do I convert an ISO 8601 string to a Delphi TDate?

前端 未结 7 1482
北海茫月
北海茫月 2020-12-06 05:09

I can convert a Delphi TDate to ISO 8601 format easily using this:

DateTimeToString(result, \'yyyy-mm-dd\', myDate);

What\'s the idiomatic

7条回答
  •  离开以前
    2020-12-06 05:37

    For more flexibility, you could consider Marco van de Voort's scandate routine which handles your string in any format:

    var
      D: TDateTime;
    begin
      D := ScanDate('yyyy-mm-dd', '2011-07-11');
    

    See final version (7kB .zip) as added to FPC.

提交回复
热议问题