How to convert python date format to 10 digit date format for mysql?
4 answers
You can use the strptime time module - you pass in a string time (like 11-05-09) and a format and it will return a struct_time from which you can get a numeric value (by calling time.mktime on the returned struct_time). See the docs fortime.strptime
details .
+4
a source to share
Use time.strptime () to convert the date to a temporary tuple and then time.mktime () (or calendar.timegm ()) to convert it to floating point time. You will probably have to truncate it to an integer after.
tm = time.strptime('11-05-09', '%d-%m-%y')
time = time.mktime(tm)
time_int = int(time)
0
a source to share