Python – How to convert python date format to 10-digit date format for thesql


how to convert python date format to 10 digit date format for mysql

date in python -> 11-05-09

to something like 1239992972 (10 digit)


Best Solution

You can use the time module's strptime - you pass in a string time (e.g. 11-05-09) and a format and it will return a struct_time, which you can get the numerical value from (by calling time.mktime on the returned struct_time). See the docs for time.strptime for further details.