Print Complete TimeTuple in Python



In this article we will show you how you can print complete TimeTuple in Python. So printing a complete timeTuple in Python is very useful when you want to extract various parts of a date. For example you can use it to get the year, month, day, hour, minute, second and microsecond from a date.

The time tuple is a tuple of 9 integers like year, month, day, hour, minute, second and microsecond. The first 6 items are required and the last 3 are optional basically. Here are different ways to do this task and print a time tuple -

Using datetime.date.today() Method

In this example we will use the datetime.date.today() method to print the complete time tuple. The datetime.date.today() method is used to get the current local date and time as a datetime object.

Here is the program -

import datetime

# Get the current date and time
now = datetime.date.today()

# Print the complete time tuple
print("The complete Time Tuple:", now.timetuple())

Output

When you run the program, it will show this output -

The complete Time Tuple: time.struct_time(tm_year=2025, tm_mon=5, tm_mday=8, tm_hour=13, tm_min=12, tm_sec=23, tm_wday=3, tm_yday=128, tm_isdst=-1)

Using datetime.date.now() Method

Here we are going to use the datetime.date.now() method to print the complete time tuple. The datetime.date.now() method is used to return the current local date and time as a datetime object.

Let us see the example below -

import datetime

# Get the current date and time
now = datetime.date.now()

# Print the complete time tuple
print("The complete Time Tuple:", now.timetuple())

Output

After running the program, you will get this result -

The complete Time Tuple: time.struct_time(tm_year=2025, tm_mon=5, tm_mday=8, tm_hour=13, tm_min=12, tm_sec=23, tm_wday=3, tm_yday=128, tm_isdst=-1)

Using a Past Date

In this example we will use a past date to print the complete time tuple. Follow the below example -

import datetime

# Create a datetime object from a past date
pdate = datetime.datetime(2023, 3, 13)

# Print the complete time tuple
print("The complete Time Tuple:", pdate.timetuple())

Output

You will see this result after executing the program -

The complete Time Tuple: time.struct_time(tm_year=2023, tm_mon=3, tm_mday=13, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=0, tm_yday=72, tm_isdst=-1)
Updated on: 2025-06-06T16:33:59+05:30

190 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements