1. Learn
  2. /
  3. Courses
  4. /
  5. Working with Dates and Times in Python

Exercise

Turning strings into datetimes

When you download data from the Internet, dates and times usually come to you as strings. Often the first step is to turn those strings into datetime objects.

In this exercise, you will practice this transformation.

Reference
%Y4 digit year (0000-9999)
%m2 digit month (1-12)
%d2 digit day (1-31)
%H2 digit hour (0-23)
%M2 digit minute (0-59)
%S2 digit second (0-59)

Instructions 1/3

undefined XP
  • 1
    • Determine the format needed to convert s to datetime and assign it to fmt.
    • Convert the string s to datetime using fmt.
  • 2
    • Determine the format needed to convert s to datetime and assign it to fmt.
    • Convert the string s to datetime using fmt.
  • 3
    • Determine the format needed to convert s to datetime and assign it to fmt.
    • Convert the string s to datetime using fmt.