how to use datetime module in python code example

Example 1: import datetime

from datetime import datetime

date = datetime.now()
print(date)
# Prints in the format year, month, day, hour, minute, second, and microsecond

Example 2: datetime python

from datetime import datetime as d
date = d.now()
print(date.strftime("%Y-%m-%d %H:%M:%S"))

Example 3: python datetime module

import datetime as d
time = d.datetime.now()
time = time.strftime("%Y-%m-%d  %H:%M:%S")
           #year-#month-#date  #hour:#minure:#second
print(time)