converting time tuple to datetime struct

M

Michael Jard

there a shorter way then:
datetime.fromtimestamp(time.mktime(time.strptime("20-3-2005","%d-%b-%y")))

thanks,
Mike
 
G

gry

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

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

Cheers,
George
 
M

Michael Jard

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

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top