Skip to content

Commit

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

0 comments on commit 7b7a347

Please sign in to comment.