Entwickler-Ecke

Delphi Language (Object-Pascal) / CLX - Zeitformat


UweK - Mi 08.12.21 17:48
Titel: Zeitformat
Hallo,

Bestimmt für den Kenner leicht zu beantworten: Gibt es eine fertige Delphi-Funktion, die Zeitangaben im Format
"2021-07-27T14:35:42" im Stück in eine TDateTime-Variable umwandelt, oder muss ich mir das zu Fuß über Teilstrings erschließen?

Ich möchte viele mit LabView erzeugte Datenfiles verarbeiten. Dort scheint das ein Standardformat zu sein.

Danke für Hinweise!


Th69 - Mi 08.12.21 20:54

Versuche mal DateUtils.TryISO8601ToDate [https://docwiki.embarcadero.com/Libraries/Rio/en/System.DateUtils.TryISO8601ToDate], ansonsten s.a. Convert UTC string to TDatetime in Delphi [https://stackoverflow.com/questions/1597754/convert-utc-string-to-tdatetime-in-delphi].


Fred - Mo 13.12.21 11:43

Hallo!

Ja da gibt es mehrere.
Eine davon:

Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
FormatDateTime('dd.mm.yyyy, hh:nn:ss', now);     // 31.12.1999 23:59:00
FormatDateTime('dd/mm/yy', now);                 // 31/12/1999
FormatDateTime('yy-mm-dd-hh-nn-ss', now);        // 99-12-31-23-59-00
FormatDateTime('d.m.yyyy', now);                 // 1.1.2000
FormatDateTime('ddd., d. mmmm yyyy hh:mm', Now); // Sa., 3. März 2018 14:27
FormatDateTime('ddd., d. mmm. yyyy', Now);       // Sa., 3. Jän. 2018 
FormatDateTime('d.m.yyyy', Now);                 // 3.3.2018

FormatDateTime('ddd, dd.mmm.yyyy - hh:mm:ss', Now); // Do., 21.Okt.2021 - 12:47:48


Th69 - Mo 13.12.21 13:00

Hallo und :welcome: Fred,

hier geht es aber um die andere Richtung, nämlich aus einem Datumstext ein TDateTime zu erzeugen (nicht umgekehrt).