datetime now python return code example
Example 1: print time python
from datetime import datetime
now = datetime.now().time() # time object
print("now =", now)
print("type(now) =", type(now))
Example 2: get date and time python
from datetime import datetime
now = datetime.now()
print (now.strftime("%Y-%m-%d %H:%M:%S"))