Convert timedelta to Minutes in Python (Example)


In this tutorial, you’ll learn how to convert a timedelta object to minutes in the Python programming language.

The tutorial consists of an example illustrating the conversion of timedelta objects into minutes. To be more precise, the article contains the following:

Let’s start right away!


Example Data & Imported Modules

Let’s import the datetime module.

import datetime                                                       # Loading datetime module

Now we should construct some data that we can use in the exemplifying code later on:

td = datetime.timedelta(days=71, seconds=34512, microseconds=150475)  # timedelta construction
print(td)                                                             # printing timedelta
# 71 days, 9:35:12.150475


Example: Calculate the Equivalent Time in Days

To convert our timedelta object called td to seconds, we will use the total_seconds() function as given below.

total_seconds = td.total_seconds()                                    # converting timedelta to seconds

Then we will divide the result by 60 to change the unit from seconds to minutes.

td_in_minutes = total_seconds / 60                                    # converting the second count to minutes
print(td_in_minutes)                                                  # printing result in minutes
# 102815.20250791666


Video, Further Resources & Summary

In case you need further information on the examples of this article, I recommend having a look at the following video on my YouTube channel. In the video, I’m explaining the Python programming syntax of this page:


The YouTube video will be added soon.


In addition, you may want to read the related posts on Statistics Globe.


To summarize: In this article, you have learned how to express the timedelta object in minutes in the Python programming language. Please let me know in the comments section, in case you have any additional comments and/or questions.


Ömer Ekiz Python Programming & Informatics

This page was created in collaboration with Ömer Ekiz. Have a look at Ömer’s author page to get further information about his professional background, a list of all his tutorials, as well as an overview on his other tasks on Statistics Globe.


Subscribe to the Statistics Globe Newsletter

Get regular updates on the latest tutorials, offers & news at Statistics Globe.
I hate spam & you may opt out anytime: Privacy Policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.