1from datetime import datetime
2now = datetime.now()
3print (now.strftime("%Y-%m-%d %H:%M:%S"))
4
5
6Output: 2020-06-19 10:34:45
1from datetime import date
2
3today = date.today()
4print("Today's date:", today)
1now_time = datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S")
2print(now_time)
1"""Imports the datetime package from the Python library"""
2from datetime import datetime
3
4"""Sets the variable now to the current date and time"""
5now = datetime.now()
6
7"""The variable current_time contains the string values of the current time"""
8current_time = now.strftime("%H:%M:%S")
9print("Current Time =", current_time)
1import datetime
2print(datetime.datetime.now()) #datetime.datetime.now() is the syntax