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 7722241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:07:13+00:00 2026-06-01T04:07:13+00:00

I am not sure I worded that correctly but python and time always confuses

  • 0

I am not sure I worded that correctly but python and time always confuses me.
This is what I am trying.
Given a unix timestamp (INT) which is definitely in the past (can be seconds ago or years ago) I want to generate a babel format_timedelta

My problem is

  1. Babel format_timedelta takes timedelta as first argument
  2. so I guess I need to generate a timedelta using time.time() (now) and the unix timestamp I have.

I can’t figure out the part 2 and I believe there must be an easier/correct way to do this. Please share the best possible way to do this, also I need it to be fast in calculating since I have to use it in a web page.

def format_starttime(value, granularity="day"):
 delta = datetime.timedelta(seconds=time.time() - value)
 return format_timedelta(delta, granularity)

gives error in date.format_timedelta()
AttributeError: ‘module’ object has no attribute ‘format_timedelta’

  • 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-01T04:07:14+00:00Added an answer on June 1, 2026 at 4:07 am
    import datetime
    
    td = datetime.timedelta(seconds=time.time()-a_unix_timestamp)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure if I worded the subject correctly but essentially I'm curious if
(I'm not sure if that title is worded correctly, as I'm still new to
Im an iphone noob. I'm not sure if I'm asking this correctly, but I
Not sure if this counts as programming related, it's a tool that I use.
Not sure if I've just missed something but this doesn't work: $(this).children('td.threadtitle a').html('thread title');
I'm not sure if this is a trivial questions but in a PHP class:
Not sure exactly what I need to do to make this work, so my
Not sure why my .plist looks like this when viwed as source code, and
Not sure if this is possible. I want to grab the latest X stories
Not sure how to do this, here is my code Dim oWeb As New

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.