Jan Markus, Thank you ! I have tried using strptime with datetime object, but it didn't work. from datetime import datetime Not working for strptime Had to, import time And use time object's struct_time fields to fetch corresponding details 30th Apr 2021, 10:06 PM ...
8. strptime() You can even do the reverse of the previous operation. If you have a time string that you want to convert to a time tuple, you can use thestrptime()function, which parses a string representing a date and time and returns a time tuple. You can then use the time tuple...
importdatetimedeftime_tango(date,time):now=datetime.datetime.now()date=now.strftime('%Y-%m-%d')time=now.strftime('%H:%M:%S:%f')dt_str=date+" "+timedt=datetime.datetime.strptime(dt_str,'%Y-%m-%d%H:%M:%S:%f')returndt 3 Answers ...