converting time tuple to datetime struct

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Jard

    #1

    converting time tuple to datetime struct

    there a shorter way then:
    datetime.fromti mestamp(time.mk time(time.strpt ime("20-3-2005","%d-%b-%y")))

    thanks,
    Mike

  • gry@ll.mit.edu

    #2
    Re: converting time tuple to datetime struct

    [your "%b" is supposed to be the abbreviated month name, not the
    number. Try "%m"]

    In [19]: datetime.dateti me(*time.strpti me("20-3-2005","%d-%m-%Y")[:6])
    Out[19]: datetime.dateti me(2005, 3, 20, 0, 0)

    Cheers,
    George

    Comment

    • Michael Jard

      #3
      Re: converting time tuple to datetime struct

      Yeah, that was just an oversight while retyping the code. Thanks from
      the prompt reply, it was just what I needed.

      Mike

      Comment

      Working...