Re: [Tutor] Converting String to Datetime

2006-03-15 Thread Kent Johnson
Ed Singleton wrote: > I seem to have a lot of questions today. Sorry. > > How can I convert a string in the format "%Y-%m-%d %H:%M:%S" into a > datetime object? > > I can work out how to convert it to a time object by: > > import time > timestring = "2005-09-01 12:30:09" > time_format = "%Y-%m-

Re: [Tutor] Converting String to Datetime

2006-03-15 Thread Ed Singleton
Nevermind. i seem to have found the answer in that wonderful PLEAC site (I always forget about that. It appears that the following works: import time, datetime timestring = "2005-09-01 12:30:09" time_format = "%Y-%m-%d %H:%M:%S" datetime.datetime.fromtimestamp(time.mktime(time.strptime(mytime, t

[Tutor] Converting String to Datetime

2006-03-15 Thread Ed Singleton
I seem to have a lot of questions today. Sorry. How can I convert a string in the format "%Y-%m-%d %H:%M:%S" into a datetime object? I can work out how to convert it to a time object by: import time timestring = "2005-09-01 12:30:09" time_format = "%Y-%m-%d %H:%M:%S" mytime = time.strptime(time