1

Here's an example string for the date/time i'm trying to convert:

10/18/2017 5:41:28 AM

This is what I'm trying to do:

x = datetime.datetime.strptime(y, "%m/%d/%Y %H:%M:%S %p")

It basically works but it ignores the %p part (the AM/PM) and carries over the hour identical to the initial string.

Is there any way to convert the AM/PM information over so my datetime object is correct in the end? I thought the %p should do this via strptime()

Helmi
  • 489
  • 7
  • 25

0 Answers0