VOOZH about

URL: https://www.geeksforgeeks.org/python/python-timedelta-total_seconds-method-with-example/

⇱ Python timedelta total_seconds() Method with Example - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python timedelta total_seconds() Method with Example

Last Updated : 6 Sep, 2021

The total_seconds() function is used to return the total number of seconds covered for the specified duration of time instance. This function is used in the timedelta class of module DateTime.

Syntax: total_seconds()

Parameters: This function does not accept any parameter.

Return values: This function returns the total number of seconds covered for the specified duration of time instance.

Example 1: In the below example, 55 minutes is going to be returned in terms of the second value with the help of total_seconds() function. 

Output:

Total seconds in 55 minutes: 3300.0

Example 2: In the below example, -3*13 minutes is going to be returned in terms of the second value with the help of total_seconds() function. 

Output:

Total seconds in -3*13 minutes: -2340.0

Example 3: In the below example, the total_seconds() function is converting the duration of "days = 2, hours = 3, minutes = 43, and seconds = 35" into its equivalent seconds value.

Output:

Total seconds are: 186215.0
Comment
Article Tags: