What time did the bike leave? (Global edition)
When you need to move a datetime
from one timezone into another, use .astimezone()
and tz
. Often you will be moving things into UTC, but for fun let's try moving things from 'America/New_York' into a few different time zones.
This exercise is part of the course
Working with Dates and Times in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create the timezone object
uk = ____
# Pull out the start of the first trip
local = onebike_datetimes[0]['start']
# What time was it in the UK?
notlocal = local.____(____)
# Print them out and see the difference
print(local.isoformat())
print(notlocal.isoformat())