471,091 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,091 software developers and data experts.

converting time tuple to datetime struct

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

thanks,
Mike

Jul 18 '05 #1
2 3954
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

Jul 18 '05 #2
Yeah, that was just an oversight while retyping the code. Thanks from
the prompt reply, it was just what I needed.

Mike

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by David Stockwell | last post: by
reply views Thread by pduncan | last post: by
4 posts views Thread by M. Uppal | last post: by
6 posts views Thread by minboymike | last post: by
14 posts views Thread by Dave Rahardja | last post: by
13 posts views Thread by HMS Surprise | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.