Back
Try:
>>> import datetime>>> datetime.datetime.now()datetime.datetime(2009, 1, 6, 15, 8, 24, 78915)>>> print(datetime.datetime.now())2009-01-06 15:08:24.789150
>>> import datetime
>>> datetime.datetime.now()
datetime.datetime(2009, 1, 6, 15, 8, 24, 78915)
>>> print(datetime.datetime.now())
2009-01-06 15:08:24.789150
then:
>>> datetime.datetime.now().time()datetime.time(15, 8, 24, 78915)>>> print(datetime.datetime.now().time())15:08:24.789150
>>> datetime.datetime.now().time()
datetime.time(15, 8, 24, 78915)
>>> print(datetime.datetime.now().time())
15:08:24.789150
You can also directly import datetime object from datetime module:
>>> from datetime import datetime
Are you interested to learn python in detail? Come and Join python certification course.
Watch this video tutorial on how to become a professional in python.
31k questions
32.8k answers
501 comments
693 users