########################################################################
import datetime
now = datetime.datetime.now()
print(now.year, now.month, now.day, now.hour, now.minute, now.second)
########################################################################
from datetime import *
now = datetime.now()
print(now.year, now.month, now.day, now.hour, now.minute, now.second)
########################################################################
import datetime
date = '2021-05-21 11:22:03'
datem = datetime.datetime.strptime(date, "%Y-%m-%d %H:%M:%S")
print(datem.day) # 25
print(datem.month) # 5
print(datem.year) # 2021
print(datem.hour) # 11
print(datem.minute) # 22
print(datem.second) # 3
# Python program to demonstrate datetime object
# import datetime class
from datetime import datetime
my_datetime = datetime(1999, 3, 8, 23, 32, 12)
print("year =", my_datetime.year)
print("month =", my_datetime.month)
print("day =", my_datetime.day)
print("hour =", my_datetime.hour)
print("minute =", my_datetime.minute)
print("timestamp =", my_datetime.timestamp())