Hint

Start by asking the user for two things: a date and a time. In Streamlit, you can do this using:

selected_date = st.date_input("Select date")
selected_time = st.time_input("Select time")

Now think: how can you combine these into a single datetime object?

from datetime import datetime
dt = datetime.combine(selected_date, selected_time)

Then you’ll need to ask the user to choose two timezones — one to convert from, and one to convert to. Use this:

import pytz
from_zone = st.selectbox("From Timezone", pytz.all_timezones)
to_zone = st.selectbox("To Timezone", pytz.all_timezones)

To actually convert the time, you’ll want to:

  1. Localize the datetime to the from_zone

  2. Use .astimezone(to_zone) to get the converted time