import datetime

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

Here is what the above code is Doing:
1. We’re importing the datetime module.
2. We’re creating a datetime object and assigning it to the date variable.
3. We’re printing the date in the format YYYY-MM-DD HH:MM:SS.