Inserting python datetime into the mysql table -
i have python date
2013-04-04t18:56:21z
i want store mysql database .
i tried
self.start_at = datetime.strptime(self.start_at.split(".")[0], "%y-%m-%dt%h:%m:%s")
but getting error
valueerror: unconverted data remains: z
please tell me how convert above date in mysql acceptable format .
in instance work.
>>> datetime import datetime >>> start_at = '2013-04-04t18:56:21z' >>> datetime.strptime(start_at , "%y-%m-%dt%h:%m:%sz") datetime.datetime(2013, 4, 4, 18, 56, 21)
are t & z characters in date format or every change? if variation in these seperator characters, should this:
>>> datetime import datetime >>> start_at = '2013-04-04t18:56:21z' >>> datetime.strptime(start_at[0:10] + ' ' + start_at[11:19], "%y-%m-%d %h:%m:%s") datetime.datetime(2013, 4, 4, 18, 56, 21)
Comments
Post a Comment