Convert 12 hour time string into datetime or time
<p>Ive been trying to use <code>time.strptime(string1,'%H:%M')</code>, with no success</p>

<p>How can I get the following:</p>

<pre><code>Input     Output
3:14AM  -&gt; 03:14
9:33PM  -&gt; 21:33
12:21AM -&gt; 00:21
12:15PM -&gt; 12:15
</code></pre>

<p>You're missing <code>%p</code> (Localeâs equivalent of either AM or PM).</p>

<pre><code>time.strptime(string1,'%H:%M%p')
</code></pre>

python datetime time