Tag Archives: date and time

How to get the current date and time in Python

Let’s say you need the current date and time from your system to place it in a Python application. For example to place the date and time as a timestamp in a blog application so the date and time when a blog article was posted will be visible on the screen.

For that, we need to import a module called datetime which contains a class with the same name datetime.

>>> import datetime
>>> current_datetime = datetime.datetime.now()
>>> print(current_datetime)
2017-12-11 08:18:18.685000

Continue reading