Add from_iso_date

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-10-28 16:20:04 +02:00
parent 7b576c1aa5
commit 7b7a347117

19
snippets/from_iso_date.md Normal file
View File

@ -0,0 +1,19 @@
---
title: from_iso_date
tags: date,intermediate
---
Converts a date from its ISO-8601 represenation.
- Use `datetime.datetime.fromisoformat()` to convert the given ISO-8601 date to a `datetime` object.
```py
from datetime import datetime
def from_iso_date(d):
return datetime.fromisoformat(d)
```
```py
from_iso_date('2020-10-28T12:30:59.000000') # 2020-10-28 12:30:59
```