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

  • SEARCH
  • Home
  • 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 8690235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:51:34+00:00 2026-06-12T23:51:34+00:00

I couldn’t find anything online and probably has some stupid simple answer, but being

  • 0

I couldn’t find anything online and probably has some stupid simple answer, but being new to python I don’t understand:

import pytz
from datetime import datetime, timedelta

now_utc = pytz.utc.localize(datetime.utcnow())
past = pytz.utc.localize(datetime.utcnow() - timedelta(seconds=120))
delta = (now_utc-past).seconds
print delta # prints '119', not '120'

Why does it always print 1 second less than the timedelta I specify? If I change “seconds=120” to “minutes=1”, I get ’59’, not ’60’. Why?

  • 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-06-12T23:51:36+00:00Added an answer on June 12, 2026 at 11:51 pm
    >>> print now_utc - past
    0:01:59.999976
    

    So there is 119 seconds and 999976 microseconds. Because you did two separate datetime.utcnow() calls with a little (24 microseconds) interval.

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

Sidebar

Related Questions

I couldn't find anything on this, but probably its just because I don't know
Couldn't find an answer to this question. It must be obvious, but still. I
Couldn't really find it, but probably it's me not knowing how to search properly
Couldn't find anything quite what I was looking for but if I've missed something
Couldn't find anything in the github documentation and also here on SO. But I
I couldn't find anything similar to this anywhere. I have an array of pointers
I couldn't find a straight answer to my question and need to know it
I couldn't find a definitive answer from the PayPal docs on this. According to
Couldn't find anything on this with a Google Search. Does anyone know how to
Couldn't find anything related to the subject in Zend Framework API. What is the

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.