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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:04:32+00:00 2026-06-11T13:04:32+00:00

I am having problem getting some datetime conversions. I am actually using django and

  • 0

I am having problem getting some datetime conversions. I am actually using django and in one of model field I used date field not datetime field. Now I need to show time difference and I got the snippet for that from djangosnippets. But that accepts timestamp.

So I am confuse that what actually is python timestamp and how can it be made. I tried different things as in below lines:

publish_date.timetuple()

but this says, that 'datetime.date' object has no attribute 'mktime'.I guess datetime.datetime has this mktime but not datetime.date so I can’t use that.

int(parse(publish_date).strftime('%s'))

Here parse is from a third party module named dateutil but this time it gives following error.

datetime.date' object has no attribute 'read'

And it gives same error for following code:

humanizeTimeDiff(publish_date)

So any better idea or approach that I should try to convert datetime.date object to timestamp. It seems like converting datetime.datetime would be also helpful. But how ?

  • 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-11T13:04:34+00:00Added an answer on June 11, 2026 at 1:04 pm

    Since you don’t have any time information in your database (only date), you can only calculate the difference in number of days. To do that, simply subtract the date objects. This will yield a timedelta object which represents the difference between two date (or datetime) objects.

    >>> d1
    datetime.date(2012, 9, 16)
    >>> d2
    datetime.date(2012, 9, 17)
    >>> d2-d1
    datetime.timedelta(1)
    >>> print d2-d1
    1 day, 0:00:00
    >>> print (d2-d1).days
    1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having problem getting my tooltip to work when using the jQuery load()
We're having a problem getting Word documents to download in IE7/IE8 using window.open calls.
I'm having some problem getting text with special characters (Swedish: åäö) from the database.
I'm having a problem getting the right date format to be returned from my
Having a problem getting some data persisted with hibernate I declare two independent classes,
Having some problem getting my program to sleep What im trying to do is
Having a problem getting the URL for a resource for some reason: This code
I'm having a problem getting some data since I'm just starting to use LINQToEntities,
I'm having some problem with getting Python to handle my unicode text correctly. I've
I'm having a problem getting some code to work with the parallel package in

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.