TIME AND CALENDAR IN PYTHON

From the previous blogs we talked about the data types in Python. From this blog I’m going to write about another important module in python, Date and Time. When we are working with the date and time we have to use Python’s inbuilt time, calendar modules. For that first of all we have to import them.

import time

import calendar

Now let’s see how we can use some  of the basic commands with date and time.

  • time()‘ gives the ticks since 12:00am, January 1, 1970.

1.png

  • localtime()‘ is used to get the localtime in parameters.

2

  • asctime()‘ make it more readable.

3.png

  • month()‘ shows a calendar in detail.

5

6

7

  • timezone()‘ gives your time zone.

8.png

  • Another useful method in use is the ‘tzname()‘.

9.png

  • isleap()‘ will find out whether a given year is a leap year or not.

10.png

These are some basic methods used in time and calendar modules. Though this is a very short post it’s much worth to talk about. Hope to see you soon with another interesting topic. Thank You!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s