Date from ISO format

Python, Date · Jan 7, 2021

Converts a date from its ISO-8601 representation.

  • Use datetime.datetime.fromisoformat() to convert the given ISO-8601 date to a datetime.datetime object.
from datetime import datetime

def from_iso_date(d):
  return datetime.fromisoformat(d)

from_iso_date('2020-10-28T12:30:59.000000') # 2020-10-28 12:30:59

More like this

  • Date to ISO format

    Converts a date to its ISO-8601 representation.

    Python, Date · Jan 7, 2021

  • Days from now

    Calculates the date of n days from today.

    Python, Date · Oct 28, 2020

  • Date range

    Creates a list of dates between start (inclusive) and end (not inclusive).

    Python, Date · Jan 7, 2021