Python datetime example

Here we will see Python datetime examples. as datetime deals with dates and times in Python.

Python datetime example

Get Current date and time

#Python datetime example

import datetime

x = datetime.datetime.now()
print(x)
2019-04-13 10:53:10.704525

 

  • To use datetime in Python, we have to import datetime module of Python.
  • using now() function of datetime we can get the current datetime in Python
Please follow and like us:
READ  Python Hello World Example