I have the data and in that data, time date format is of type 2017-11-01 00:00:00-04:00. I want to strip -4:00 and have to use the remaining.
I did everything but no successs.
I have the data and in that data, time date format is of type 2017-11-01 00:00:00-04:00. I want to strip -4:00 and have to use the remaining.
I did everything but no successs.
from datetime import datetime
date_string = '2017-11-01 00:00:00-04:00'
date = datetime.strptime(date_string, '%Y-%m-%d %H:%M:%S%z')
print(date)
# Returns: 2017-11-01 00:00:00-04:00
print(date.strftime("%Y-%m-%d %H:%M:%S"))
# Retruns: 2017-11-01 00:00:00