Reputation: 3
This is my code:
shift_from = datetime.strptime(shift_change_ob.shift_date, '%Y-%m-%d %H:%M:%S')
shift_to = datetime.strptime(shift_change_ob.shift_date_to, '%Y-%m-%d %H:%M:%S')
shift_time_from = self.get_zone_time(shift_from)
shift_time_to= self.get_zone_time(shift_to)
time_from = datetime.strptime(str(shift_time_from),"%Y-%m-%d %H:%M:%S").strftime("%H.%M")
time_to = datetime.strptime(str(shift_time_to),"%Y-%m-%d %H:%M:%S").strftime("%H.%M")
I want to get only time from shift_time_from
and shift_time_to
. When I do this I get:
ValueError: unconverted data remains: +00:00
How can I solve this?
Upvotes: 0
Views: 721
Reputation: 80
If shift_from
and shift_to
are correct, then use the method time
for getting only time part:
shift_time_from = shift_from.time()
shift_time_to = shift_to.time()
Upvotes: 1