Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6338959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:33:17+00:00 2026-05-24T19:33:17+00:00

This question originated when I came upon ( another thread ) about Python’s datetime

  • 0

This question originated when I came upon (another thread) about Python’s datetime and timedelta objects.

I followed the update by jimgardener and read the comments by eyquem ,and tried out some python code ..I am having a bad time understanding the way things work here(due to my newbie to python status)..I thought it was proper to ask a new question

import datetime
#for t1=23:30:00 PM
t1 = datetime.time(23,30,00)

#for t1=00:15:30 AM
t2 = datetime.time(0,15,30)

td1 = datetime.timedelta(hours=t1.hour,minutes = t1.minute,seconds=t1.second)

td2 = datetime.timedelta(hours=t2.hour,minutes = t2.minute,seconds=t2.second)

#substarcting timedeltas
tdiff = td2-td1

printing these variables yielded

td1 ==> datetime.timedelta(0, 84600)
td1.seconds ==> 84600

td2 ==> datetime.timedelta(0, 930)
td2.seconds ==> 930

tdiff ==> datetime.timedelta(-1, 2730)

When I looked at these results,I noticed that

td1.seconds (ie 84600) is equivalent to 
84600/60 ==> 1410 minutes
1410/60 ==> 23.5 hours
or in short,td1 represents the duration **from previous midnight** to 23:30 PM

now ,

td2.seconds (ie 930) is equivalent to
930/60 ==> 15.5 minutes or 15 minutes and 30 seconds
which means td2 represents the duration from **that midnight**
 to 00:15:30 AM

when tdiff is examined,I found that

tdiff ==> timedelta(-1,2730)
tdiff.seconds ==> 2730
tdiff.seconds/60 ==>45 minutes

this is the same as duration between t1(23:30:00 PM) and t2(00:15:30 AM) assuming that t2 follows t1

My question is,since td1 is the duration from previous midnight
to 23:30:00 PM and td2 is the duration from that midnight
to 00:15:30 AM , how can their difference represent the duration between t2 and t1 ?

Can some python gurus explain

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:33:18+00:00Added an answer on May 24, 2026 at 7:33 pm

    The timedeltas don’t represent time from a midnight, just an amount of time.

    If it took me three hours minus four hours to do something, it would take me negative one hour.

    The difference between the two timedeltas is negative one day plus 45 minutes.

    This is the same as negative 23 hours and 15 minutes.

    15 minutes minus 23 hours and 30 minutes is negative 23 hours and 15 minutes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is about HTTPD (Apache) 2.? on centOS and modperl 1.7+ When I
This question is specific to Erlang, but may have general implications to other IO
This question aims to understand RoR and frameworks in general. It looks like RoR
My specific problem is actually not about the general translation of an OO interface
I am running a service hosted on a server in the US which reads
Suppose I have 2 web services A and B in SOA project. Both web
I have an AJAX intensive web application where the requests are unsecured, meaning there
I have a button in a rather complex repeater, it has to have UseSubmitBehavior=False
The system I'm working on is using something like a dynamic router + dep.injection
Been integrating AuthNet's Automated Recurring Billing system alongside its Silent Post feature to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.