Menu Close

How to get the current time with Python?

Sometimes, we want to get the current time with Python.

In this article, we’ll look at how to get the current time with Python.

How to get the current time with Python?

To get the current time with Python, we can use datetime.datetime.now().time().

For instance, we write

t = datetime.datetime.now().time()

to get the current datetime with datetime.datetime.now().

And then we get the time of the current datetime with time.

Conclusion

To get the current time with Python, we can use datetime.datetime.now().time().

Posted in Python, Python Answers