Python Tutorial
Python - Introduction Python - Syntax Python - Variable Python - Number Python - Casting Python - String Python - Operators Python - Conditions Python - Loops Python - List Python - Tuple Python - Set Python - Dictionary Python - Function Python - Module Python - Date & Time Python - Input Output Python - Error & Exception Python - File Handling
Python OOP
OOP - Introduction OOP - Class Members OOP - Constructor Destructor OOP - Data Hiding OOP - Inheritance OOP - Overriding OOP - Overloading

Python Date & Time

A Python program can handle date and time in several ways.

Converting between date formats is a common chore for computers.

Python's time and calendar modules help track dates and times.


Python time module

There is a popular time module available in Python which provides functions for working with times, and for converting between representations. The function time.time() returns the current system time in ticks since 12:00am, January 1, 1970(epoch).



Pausing program execution

You can use sleep() function of time module to pause execution of your program.


Python calender module

The calendar module gives a wide range of methods to play with yearly and monthly calendars.

Here, we print a calendar for a given year (2018, 5):

The above code will display the following output:

May 2018
Mo Tu We Th Fr Sa Su
1  2  3  4  5  6
7  8  9  10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31