How to get the current date and time in Python

Today we are going to share how to get the current date and time in Python. If you are a python beginner and want to start learning the python programming, then keep your close attention in this tutorial as I am going to share how to get the current date and time in Python.

To increase your Python knowledge, practice all Python programs:

How to get the current date and time in Python

Copy the below python program and execute it with the help of python compiler.

Output

Current date and time using str method of datetime object:
2013-02-17 16:02:49.338517
Current date and time using instance attributes:
Current year: 2013
Current month: 2
Current day: 17
Current hour: 16
Current minute: 2
Current second: 49
Current microsecond: 338517
Current date and time using strftime:
2013-02-17 16:02

Recommended Posts:


Editorial Staff

Editorial Staff at FreeWebMentor is a team of professional developers leads by Prem Tiwari

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Solved Programs