@@ -205,11 +205,12 @@ F-string:
205205 >>> print(f"My name is {uid.capitalize()=}")
206206 My name is uid.capitalize()='Veit'
207207
208- Formatting date and time formats and IP addresses
209- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
208+ Formatting date and time formats
209+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
210210
211211:py:mod: `datetime ` supports the formatting of strings using the same syntax as
212- the :py:meth: `strftime <datetime.datetime.strftime> ` method for these objects.
212+ the :py:meth: `datetime.strftime <datetime.datetime.strftime> ` method for these
213+ objects.
213214
214215.. code-block :: pycon
215216
@@ -220,7 +221,26 @@ the :py:meth:`strftime <datetime.datetime.strftime>` method for these objects.
220221 'de_DE.utf-8'
221222 >>> today = datetime.date.today()
222223 >>> print(f"Heute ist {today:%A, %d. %B %Y}.")
223- Heute ist Dienstag, 25. November 2025.
224+ Heute ist Freitag, 11. Juli 2025.
225+
226+ Conversely, you can also use :meth: `datetime.strptime
227+ <datetime.datetime.strptime> ` to convert strings into ``datetime `` objects:
228+
229+ .. code-block :: pycon
230+
231+ >>> today_string = "Fri, 11 Jul 2025 18:46:49"
232+ >>> today = datetime.datetime.strptime(today_string, "%A, %d. %B %Y")
233+
234+ .. csv-table :: Häufige Formatierungen
235+ :header: "Beschreibung", "Beispiel", "Format"
236+
237+ ISO 8601, "2025-07-11T18:46:49", "%Y-%m-%dT%H:%M:%S"
238+ ISO 8601 with time zone, "2025-07-11T18:46:49+0100", "%Y-%m-%dT%H:%M:%S%z"
239+ RFC 2822, "Fr, 11 Jul 2025 18:46:49", "%a, %d %b %Y %H:%M:%S"
240+ RFC 3339 with time zone, "2025-07-11 18:46:49+0100", "%Y-%m-%d %H:%M:%S%z"
241+
242+ Formatting IP addresses
243+ ~~~~~~~~~~~~~~~~~~~~~~~
224244
225245The :py:mod: `ipaddress ` module of Python also supports the formatting of
226246``IPv4Address `` and ``IPv6Address `` objects.
0 commit comments