How do I find the days to a date with 'time()' ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raubana
    New Member
    • Feb 2008
    • 55

    How do I find the days to a date with 'time()' ?

    How do I find the days to a date with 'time()' ? Of course, this is a very noobish question, but as it turns out doing this can be really tough. Can anyone help me?
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Here's one way of doing it:[code=Python]>>> import datetime, time
    >>> present = datetime.dateti me.now()
    >>> future_date = '5/12/2009'
    >>> delta = datetime.dateti me(*time.strpti me(future_date, '%m/%d/%Y')[:6])-present
    >>> delta.days
    364
    >>> delta.seconds
    40855
    >>> [/code]

    Comment

    • raubana
      New Member
      • Feb 2008
      • 55

      #3
      Cool, thanks a ton! (; P)

      Comment

      Working...