learnpython24-(Python datetime)
Python datetime In this article, you will learn to manipulate date and time in Python with the help of examples. Python has a module named datetime to work with dates and times. Let's create a few simple programs related to date and time before we dig deeper. Example 1: Get Current Date and Time import datetime datetime_object = datetime.datetime.now() print (datetime_object) When you run the program, the output will be something like: 2018-12-19 09:26:03.478039 Here, we have imported datetime module using import datetime statement. One of the classes defined in the datetime module is datetime class. We then used now() method to create a datetime object containing the current local date and time. Example 2: Get Current Date import datetime date_object = datetime.date.today() print (date_object) When you run the program, the output will be something like: 2018-12-19 In this program, we have us...