Add to_iso_date

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-10-28 16:20:50 +02:00
parent 52de9547d9
commit 36f73d80e3

21
snippets/to_iso_date.md Normal file
View File

@ -0,0 +1,21 @@
---
title: to_iso_date
tags: date,intermediate
---
Converts a date to its ISO-8601 represenation.
- Use `datetime.datetime.isoformat()` to convert the given `datetime` object to an ISO-8601 date.
```py
from datetime import datetime
def to_iso_date(d):
return d.isoformat()
```
```py
from datetime import datetime
to_iso_date(datetime(2020,10,25)) # 2020-10-25T00:00:00
```