How to print current date on python3? How to print current date on python3? python python

How to print current date on python3?


import datetimenow = datetime.datetime.now()print(now.year)

The above code works perfectly fine for me.


The following seems to work:

import datetimeprint (datetime.datetime.now().strftime("%y"))

The datetime.data object that it wants is on the "left" of the dot rather than the right. You need an instance of the datetime to call the method on, which you get through now()


I use this which is standard for every time

import datetimenow = datetime.datetime.now()print ("Current date and time : ")print (now.strftime("%Y-%m-%d %H:%M:%S"))