Nest all content into snippets

This commit is contained in:
Angelos Chalaris
2023-05-07 16:07:29 +03:00
parent 2ecadbada9
commit 6a45d2ec07
1240 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,25 @@
---
title: Date to ISO format
type: snippet
language: python
tags: [date]
cover: succulent-red-light
dateModified: 2021-01-07T23:30:28+02:00
---
Converts a date to its ISO-8601 representation.
- Use `datetime.datetime.isoformat()` to convert the given `datetime.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
```