forked from Chalarangelo/30-seconds-of-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |