Getting the current date and time in Python

In Python, to work with date and time, you have to import the datetime module. in datetime module there is a datetime object represents both date and time. If you want to get the current date and time of the system where you are running the Python program, use the method datetime.now(). Here is an example.

import datetime

print( datetime.datetime.now() )
getting current date and time in Python

See more Python Tips.

Reference

Related Articles & Tools

Leave your thoughts...

This site uses Akismet to reduce spam. Learn how your comment data is processed.