Skip to content

Commit

Permalink
Add to_iso_date
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinityyi committed Oct 28, 2020
1 parent 52de954 commit 36f73d8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions snippets/to_iso_date.md
Original file line number Diff line number Diff line change
@@ -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
```

0 comments on commit 36f73d8

Please sign in to comment.