

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is a TimeTuple in Python?
The timetuple() method of datetime.date instances returns an object of type time.struct_time. The struct_time is a named tuple object (A named tuple object has attributes that can be accessed by an index or by name).
The struct_time object has attributes for representing both date and time fields along with a flag to indicate whether Daylight Saving Time is active.
The named tuple returned by the timetuple() function will have its year, month and day fields set as per the date object and fields corresponding to the hour, minutes, seconds will be set to zero.
example
import datetime todaysDate = datetime.date.today() timeTuple = todaysDate.timetuple() print(timeTuple) print(timeTuple.tm_year)
Output
This will give the output −
time.struct_time(tm_year=2017, tm_mon=12, tm_mday=28, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=362, tm_isdst=-1) 2017
- Related Questions & Answers
- What is TimeTuple in Python?
- How to print complete TimeTuple in Python?
- What is a namespace in Python?
- What is a Tick in python?
- What is a metaclass in Python?
- What is a Python bytestring?
- What is a regular expression in Python?
- What is a dot operator in Python?
- What is a file descriptor used in Python?
- What is a sequence data type in Python?
- What is immutable in Python?
- What is @ operator in Python?
- What is iterweekdays() in python?
- What is itermonthdates() in python?
- What is itermonthdays2() in python?
Advertisements