Gunnar Bittersmann: Text aufteilen mit HTML-Tags

Beitrag lesen

@@Folllast

Die Herausforderung: das Datum wird in der Tabelle so gespeichert: "202105072145".

Als String? Oder ist das das Datumsformat des verwenderen Datenbank-Systems?

Nach dem Auslesen aus der Datenbank (eine solche meinst du doch mit „Tabelle“, oder?) kannst du den String ja umwandeln, z.B. mit regularem Ausdruck (\d{4})(\d{2})(\d{2})(\d{2})(\d{2}) (4 Ziffern fürs Jahr, dann jeweils 2 Ziffern für Monat, Tag, Stunde, Minute). Die Matches hast du dann in $1 bis $5, daraus kannst dann sowas bauen:

<time datetime="$1-$2-$3 $4:$5">$3.$2.$1 $4:$5</time> (Pseudocode).

😷 LLAP

--
“When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down ‘happy.’ They told me I didn’t understand the assignment, and I told them they didn’t understand life.” —John Lennon