How to Get the Current Date and Time in Python

In python, we can get the current date and time using the datetime object. In the datetime module, the now() function gives us the current local date and time.

The below example shows how to get the current date and time using the now() function:

import datetime
print(“Current Date and Time:”,current_datetime)
Current Date and Time: 2023-01-01 01:15:13.121315
I have an another article How to Format Date Time Data Object in Python, from where you can learn about different parameters date time formatting in Python.
In this tutorial, I tried to brief how to get the current Date and Time in Python. Hope you have enjoyed the tutorial. If you want to get updated, like my facebook page and stay connected.

Add a Comment