1import datetime
2date = '2021-05-21 11:22:03'
3datem = datetime.datetime.strptime(date, "%Y-%m-%d %H:%M:%S")
4print(datem.day) # 25
5print(datem.month) # 5
6print(datem.year) # 2021
7print(datem.hour) # 11
8print(datem.minute) # 22
9print(datem.second) # 3
1import datetime
2now = datetime.datetime.now()
3print(now.year, now.month, now.day, now.hour, now.minute, now.second)