How to convert "12:45pm - 01:00pm Today, September 7" into UTC
<p>I have the following time string </p>

<pre><code>12:45pm - 01:00pm Today, September 7
</code></pre>

<p>and I want to convert this string into UTC datetime in the following format</p>

<pre><code>2016-09-07T22:45:00Z
</code></pre>

<p>How can I achieve this in python?</p>

<pre><code>developed the script to achieve it.

    def appointment_time_string(time_str):
        import datetime
        a = time_str.split()[0]

        in_time = datetime.datetime.strptime(a,'%I:%M%p')

        start_time = str(datetime.datetime.strftime(in_time, "%H:%M:%S")) + "Z"

        if time_str.split()[3] == 'Today,':
            start_date = datetime.datetime.utcnow().strftime("%Y-%m-%dT")
        elif time_str.split()[3] == 'Tomorrow,':
            today = datetime.date.today( )
            start_date = (today + datetime.timedelta(days=1)).strftime("%Y-%m-%dT")

        appointment_time = str(start_date) + str(start_time)

        return appointment_time
</code></pre>

python