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

Connected

Exercise

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.

Instructions 1/3

undefined XP
  • 1
    • Set uk to be the timezone for the UK: 'Europe/London'.
    • Change local to be in the uk timezone and assign it to notlocal.
  • 2
    • Set ist to be the timezone for India: 'Asia/Kolkata'.
    • Change local to be in the ist timezone and assign it to notlocal.
  • 3
    • Set sm to be the timezone for Samoa: 'Pacific/Apia'.
    • Change local to be in the sm timezone and assign it to notlocal.