title: Convert HH:MM:SS AM/PM string to time
body: <p>I need to parse times in a character format like &quot;1:36:22 PM&quot;.</p>
  <p>I've tried various permutations of <code>as.POSIXct</code> and <code>strptime</code> but just can't get there. For example, this fails to pick up the importance of PM:</p>
  <pre><code>t &lt;- &quot;1:36:22 PM&quot;
  as.POSIXct(t, format = &quot;%H:%M:%S&quot;)
  # [1] &quot;2016-09-08 01:36:22 BST&quot;
  </code></pre>
  <p>and this fails:</p>
  <pre><code>strptime(t, &quot;%H:%M:%S&quot;)
  # [1] NA
  </code></pre>
  <p>Curiously, for reasons I can't understand, dropping the seconds from the input <em>may</em> work:</p>
  <pre><code>t &lt;- &quot;1:30:00 PM&quot;
  strptime(t, &quot;%I:%M %p&quot;)
  # [1] NA
   
  t &lt;- &quot;1:30 PM&quot;
  strptime(t, &quot;%I:%M %p&quot;)
  # [1] &quot;2016-09-08 13:30:00 BST&quot;
  </code></pre>
  <p>All I want is for this to work:</p>
  <pre><code>t &lt;- &quot;1:30:00 PM&quot;
  SOME COMMAND HERE HERE
  # [1] &quot;13:30:00&quot;
  </code></pre>
  <p>Any ideas?</p>