Reputation: 37
I am extracting date from Sql Query executed using selenium Python. The date variable shows up as datetime.datetime(2020, 8, 27, 4, 16, 33)
and I need to change the format in "YYYY-MM-DD HH:MM:SS". Please help.
Upvotes: 1
Views: 6155
Reputation: 2025
import datetime
x = datetime.datetime(2020, 8, 27, 4, 16, 33)
x.strftime('%Y-%m-%d %H:%M:%S')
it returns
'2020-08-27 04:16:33'
Upvotes: 5