Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Dates and Times in Python (2014) Dates and Times Today and Tomorrow

Sahar Nasiri
Sahar Nasiri
7,454 Points

Timedelta.minute

Timedeltas do not have a .minute property Timedeltas do have a .second property.

I tested timedelta.minute and it does work!

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

According to the timedelta docs

A timedelta can be specified using class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)

One created, timedelta all argument values are converted the three attributes:

Instance attributes (read-only):

Attribute      Value
days           Between -999999999 and 999999999 inclusive
seconds        Between 0 and 86399 inclusive
microseconds   Between 0 and 999999 inclusive

And has the instance attribute:

timedelta.total_seconds()
Return the total number of seconds contained in the duration. Equivalent to td / timedelta(seconds=1).

So to get the number of minutes use int(datetime.timedelta.total_seconds() / 60)