Feb-22-2018, 11:43 PM
Hi all,
I am sorry for making another post 3 times in a week, but I am almost complete my project. I have converted from
When I try this:
The error are highlight on this line:
Can you please help me with how we can solve the error to allow me to convert it back to
Thanks in advance
I am sorry for making another post 3 times in a week, but I am almost complete my project. I have converted from
time.struct_time
to datetime
object. Now I would like to convert it back to time.struct_time
object after I have added to the next day date. When I try this:
half_hour_date = '23/02/2018 23:00PM' epg_time_1 = time.strptime(half_hour_date, '%d/%m/%Y %I:%M%p') #convert from time_struct_time object to datetime date_format = datetime.datetime.fromtimestamp(time.mktime(epg_time_1)) half_hour = date_format + datetime.timedelta(days = self.program_day) #convert from datetime to time_struct_time object epg_time_1 = time.strptime(half_hour, '%d/%m/%Y %I:%M%p')It give me an error: TypeError: expected string or buffer
The error are highlight on this line:
epg_time_1 = time.strptime(half_hour, '%d/%m/%Y %I:%M%p')Here is the datetime object for
half_hour
:2018-02-23 23:00:00I don't have a clue what to do as I don't know how to fix it. What I am trying to do is to get the day, month, year, 12 hours time, minutes with PM to make it to show like "23/02/2018 23:00PM" from variable called
half_hour
Can you please help me with how we can solve the error to allow me to convert it back to
time.struct_time
object?Thanks in advance