views:

169

answers:

1

i have string

date = "11/28/2009"
hour = "23"
minutes = "59"
seconds = "00"

how can i convert to datetime object and store it in datastore?

+4  A: 

I apologize if this isn't what you want, but at least for the first part of the question you could probably do it like so?

>>> import datetime
>>> datetime.datetime.strptime(date + ' ' + hour + ':' + minutes + ':' + seconds, '%m/%d/%Y %H:%M:%S')
datetime.datetime(2009, 11, 28, 23, 59)
meder
thx!! this is the correct answer. store in datastore will be sth like:record = Model()record.date = datetime.datetime.strptime(date + ' ' + hour + ':' + minutes + ':' + seconds, '%m/%d/%Y %H:%M:%S')record.put()
joetsuihk