I am trying to convert time data which is displayed in hours minutes and seconds into standard time. I want to discard the seconds as well. I'm selecting datetime from mysql like this
time = connect("SELECT","""SELECT datTime FROM myTable WHERE ID = 1;""")
I then get only the time by doing this
time = time[0][0].time()
And I have tried various methods of converting the time into standard time minus the seconds such as
noSeconds = time.strftime("%H:%M")
timeNoSec = datetime.strptime(noSeconds, '%H:%M')
standardTime = noSeconds.strftime('%I:%M %p')
print(standardTime)
but I just get the following error
standardTime = noSeconds.strftime('%I:%M %p')
AttributeError: 'str' object has no attribute 'strftime'
time_tvalue, seconds since 1/1/1970, as returned bytime.time()? Thedatetimemodule calls this a timestamp. Look for thetotimestampmethods. Perhaps you should show an example of exactly what string you want.timeNoSec.strftime('%I:%M %p')? Or directlytime[0][0].strftime('%I:%M %p')?